LaTeX
Reference
- Related pages on this wiki
- External references
- Manuals:
- Wiki
- Tips
- Nice styles
- Creating .EPS with VISIO
- Importing Graphics (\includegraphics, \usepackage{graphicx})
- Beamer by Example (TUG) (\onslide, \only)
- LaTeX/Presentations
- Beamer gallery — list of available themes for presentation, with screenshots.
Install
Any Linux
See TeXLive.
Ubuntu
See Ubuntu reference page or TUG Debian/Ubuntu reference page.
- Default version on Precise 12.04 is TexLive 2009, but there is a texlive-backports ppa backports ppa repository providing TexLive 2012 (see [1])
sudo add-apt-repository ppa:texlive-backports/ppa
- Follow this guide to install TexLive 2013 on Ubuntu.
- Minimum install
sudo apt-get install texlive
sudo apt-get install texlive2html # To support TeX to HTML conversion
sudo apt-get install texlive-xetex # To install XeTeX
Invocation
Basic commands for LaTeX documents (using TeXlive under Linux or MikTeX under Windows):
pdflatex <file.tex> # Convert a .tex file directly to pdf format
latex <file.tex> # Convert a .tex file to .dvi file
dvips <file.dvi> # Convert a .dvi file to .ps
dvipdfm -p a4 <filetex> # Convert a .dvi file to .pdf (using a4 paper)
For TeX documents:
pdftex <file.tex> # Convert a .tex directly into .pdf
tex <file.tex> # Convert a .tex into .dvi
For XeLaTex documents (with BibTex entries):
xelatex <file.tex> # Generate the .aux file needed by BibTex
bibtex <file.aux> # Process bib entries
xelatex <file.tex> # 1st pass will generate .pdf w/o references
xelatex <file.tex> # 2nd pass will generate .pdf w/ references
Alternative to bibtext:
- biblatex (optionally with the back-end biber)
Packages
List of packages
- eledmac — Typeset scholarly editions (when lots of footnotes, endnotes are used).
algorithmicx, algorithmic2e (algorithms)
(See LaTeX wikibooks for a comparison of algorithm typesetting packages).
algorithmicx (manual algorithmicx.pdf, debian texlive-science) is a package to typeset algorithms either in pseudo-code or in real language (Pascal and C for now).
There are 2 pseudocode layouts. The layout algcompatible
is fully compatible with older package algorithmic, except for the following differences:
- Include package algorithmicx and algcompatible instead of algorithmic:
\usepackage{algorithmicx}
\usepackage{algcompatible}
- No
\RETURN
statement. This can be defined as
\algloopdefx{RETURN}[0]{\textbf{return} \ }
% Alternate definition:
% \newcommand{\RETURN}{\State \textbf{return} \ }
- With algorithmic, empty lines were obtained with
\\ ~ \\
. There is a dedicated command in algorithmicx:
\Statex % Insert empty un-numbered line
Otherwise it is recommended to use layout algpseudocode, which uses the same commands but with a different letter case and allows defining new commands. Below is a summary of available commands.
\begin{algorithmic}[1]
\State $sum\gets 0$
\Statex
\textbf{return} $sum$\Comment{The sum is $sum$}
\end{algorithmic}
\For{<text>}
<body>
\EndFor
\ForAll{<text>}
<body>
\EndFor
\While{<text>}
<body>
\EndWhile
\Repeat
<body>
\Until{<text>}
\If{<text>}
<body>
\ElsIf{<text>}
<body>
\Else
<body>
\EndIf
\Procedure{<name>}{<params>}
<body>
\EndProcedure
\Function{<name>}{<params>}
<body>
\EndFunction
\Loop
<body>
\EndLoop
\Require something
\Ensure something
\Statex
\State \Call{Create}{10}
Save, restore algorithms:
\algstore{<savename>}
\algstore*{<savename>}
\algrestore{<savename>}
\algrestore*{<savename>}
algorithmic2e (manual algorithm2e.pdf) is yet another package, which as of 2013, seems to be the most frequently used package bundle [2]. It has a nice option to draw vertical lines for delimiting blocks, but looks more complicated and harder to read.
cleveref, varioref (smart references)
The cleveref (manual cleveref.pdf, debian texlive-latex-extra) package enhances LaTeX cross-referencing features, allowing the format of references to be determined automatically according to the type of reference.
From the manual:
- The cleveref package must be loaded after all other packages that don't specifically support it (see manual, §13). Also note that all
\newtheorem
definitions must be placed after the cleveref package is loaded.
% Load cleveref as last package!
\usepackage{cleveref}
\usepackage[capitalise]{cleveref} % Always capitalize labels
\usepackage[noabbrev]{cleveref} % Never use abbreviations in labels
\newtheorem{theorem}{Theorem} % These must come AFTER loading cleveref
\newtheorem{myclaim}{Claim}
- Most frequently used commands:
\cref{label} % Insert a reference, including label
\Cref{label} % ... idem, but at the beginning of a sentence
\crefrange{label1}{label2} % Insert a range of references
\Crefrange{label1}{label2} % ... idem, but at the beginning of a sentence
- Don't use cleveref with
eqnarray
. Use amsmath better alternatives. - cleveref conflicts with algorithmic package, so use algorithmicx package instead. Unfortunately this is not possible with IEEE publication since algorithmic is included by default.
listings, minted (source listings)
- Reference: [3]
listings is the old-fashioned way to insert code listings in LaTeX.
minted (manual minted.pdf, debian texlive-latex-extra) is a package that facilitates expressive syntax highlighting using the powerful Pygments library. It requires :
sudo apt-get install python-setuptools
sudo easy_install Pygments
All .tex files using minted must be compiled with option -shell-escape:
xelatex -shell-escape myfile.tex
Some minimal examples (see manual for more):
\begin{minted}{python}
def boring(args = None):
pass
\end{minted}
\mint{python}|import this|
% Use ''listing'' environment when adding a caption / label
\begin{listing}[htb] % Use [H] to force listing HERE
\mint{cl}/(car (cons 1 ’(2)))/
\caption{Example of a listing.}
\label{lst:example}
\end{listing}
Listing \ref{lst:example} contains an example of a listing.
soul
Use package soul (manual soul.pdf, debian texlive-plain-extra) to highlight, underline, hyphenate texts, or use small caps and change kerning, letter spacing. See manual for details.
LaTeX example:
\documentclass[a4paper]{article}
\usepackage{color,soul}
\begin{document}
Some normal text.\par
\hl{Some highlighted text.}\par
Some more normal text.
\end{document}
TeX example (requires color package from CTAN, see manual):
\input color
\input soul.sty
\pdfoutput=1
\pdfpagewidth=21cm
\pdfpageheight=29.7cm
Some text here\par
\hl{Some highlighted text now}\par
Some more text\par
\bye
Troubleshooting Reconstruction error:
\hl{match of next brace, bracket, comment, \tt\#define} % WRONG
\hl{match of next brace, bracket, comment, \tt \#define} % CORRECT
\hl{/$s$\enter\ ?$s$\enter} % WRONG
\hl{{/$s$\enter} {?$s$\enter}} % CORRECT
\hl{These are {\it italic words} and these not} % WRONG
\hl{These are \it italic words \rm and these not} % CORRECT
Font, Font Packages, and Managing Fonts
- Some fonts
- List of TeX fonts
- Computer Modern (package ???)
- The original TeX font designed in MetaFont. Now exists in scalable version in Type 1, TrueType and OpenType (see also debian package cm-super).
- Latin Modern (package lmodern)
- The Latin Modern fonts are enhanced versions of the Computer Modern fonts. They have enhanced metrics and glyph coverage.
- Utopia (package fourier)
%\usepackage[T1]{fontenc}
%\usepackage[adobe-utopia]{mathdesign}
\usepackage{fourier}
- Managing fonts
- If LaTeX complains about fonts, maybe you need to update the pdftex.map:
updmap
- In document, it seems good to select Type 1 encoding, whatever it means. However this seems automatic in recent TexLive version:
\usepackage[T1]{fontenc}
- Some references and font troubleshooting links
- Which LaTeX font packages contain real small caps and work with the “microtype” package? [4],
- Why do I suddenly get an auto expansion error? [5]
- pdfTeX error (font expansion): auto expansion is only possible with scalable [6]
Reference
Basic
Special characters | \# \$ \% \^{} \& \_ \{ \} \~{} \textbackslash
|
LaTeX Commands | \TeX{} and % space (tx to {})
\TeX{}nicians and % NO space
\TeX perts. % NO space
|
Document class | \documentclass[options]{class} % See manual for reference
|
Packages | \usepackage[options]{package} % See manual for list of packages
|
Page style | \pagestyle{style} % plain, headings, empty
\thispagestyle{style} % for current page only
|
Big project | \include{filename} % Insert content of file - LaTeX starts a new page
\includeonly{filename,...} % (in preamble) restrict list of included files
\input{filename} % Simply includes the file
|
Breaks | Supercalifragilist%
icexpialidocious % Use % to break lines without inserting space in output (here single word)
\\ % Start a new line without starting a new paragraph
\newline % idem
\\* % idem, but prohibits page break after forced line break
\newpage %
\linebreak[n] % Suggest LaTeX where to break (or not) page (n=0..4)
\nolinebreak[n] %
\pagebreak[n] %
\nopagebreak[n] %
\sloppy % Tell LaTeX to relax its layout standards
\fussy % Reset to default layout behaviour
|
Hyphenation | \hyphenation{FORTRAN Hy-phen-a-tion} % Instruct LaTex where (and not) insert hyphens
su\-per\-cal\-i\-frag % Instruct hyphen locally (handy for accented words)
\mbox{0116 291 2319} % Content of \mbox is kept togetter
\fbox{0116 291 2319} % Idem, with surrounding box
|
Special characters and symbols | `x' % single quotation marks
``quote'' % double quotation marks
daughter-in-law % 'hyphen' dash
pages 13--67 % 'en-dash'
yes---or no? % 'em-dash'
$0$, $1$ and $-1$ % 'minus' sign
http://www.clever.edu/$\sim$demo % tilde for url (better than \~{})
5MB/s % slash, but hyphenation disabled
read\slash write % slash, with hyphenation allowed
$-30\,^{\circ}\mathrm{C}$ % degree symbol
30 \textcelsius{} % idem, easier (with package 'textcomp')
\texteuro, \euro, € % various ways to get euro sign (see manual for variants)
\ldots \cdots % ellipsis (low dots), centered dots
\dotsc \dotsb \dotsm \dotsi \dotso% semantics dots, for: commas, binary ops, multiply, integrals, other
not shelfful, but shelf\mbox{}ful % use \mbox{} to prevent ligatures
H\^otel na\"\ive \'el\`eve % some example of accents (see manual for more)
|
International support | \usepackage[utf8]{inputenc} % Enable utf-8 (see also XeLaTeX)
% French support
M\up{me}, D\up{r}, 1\ier{}... % See manual for more
|
Spacing | Not\ expandable space % non-expandable space
Mr.~Smith % Idem + non-breakable
I like BASIC\@. What about you? % Indicate . is end of sentence
|
Titles, Chapters, Sections | \chapter[Shorter title]{...} % For 'report' or 'book' class
\part{...} % Does not influence section / chapter numbering
\appendix{...} % Like chapters, using letters for numbering
\section{...}
\section*{...} % unnumbered section, not in TOC
\subsection{...}
\subsubsection{...}
\paragraph{...}
\subparagraph{...}
\tableofcontents
\title{...} \author{...} \date{...}
\maketitle
|
Cross References | \label{sec:this}
See section~\ref{sec:this}
See page~\pageref{sec:this}
As in equation~\eqref{eq:this}
|
Footnotes | \footnote{text} % after word or sentence (i.e. after comma or dot)
|
Emphasized Words | \underline{text}
\emph{text}
|
Subscript and superscript | \usepackage{xltxtra}
CO\textsubscript{2}
4\textsuperscript{th}
|
Environments | \begin{itemize}
\item one
\item[-] two with a dash
\end{itemize}
\begin{enumerate}
\item first
\item second
\end{itemize}
\begin{description}
\item[One] one
\item[Second] second
\end{description}
\begin{flushleft} \end{flushleft} % Can also be used as \flushleft, \flushright...
\begin{flushright} \end{flushright}
\begin{center} \end{center}
|
Mathematics
Fractions | \frac{1}{\sqrt{2}+\frac{1}{\sqrt{2}+\frac{1}{\sqrt{2}+\dotsb}}} % Standard fraction
\cfrac{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+\dotsb
}}} % Continued fraction
\tfrac{1}{2} % Tiny fraction, like in textstyle
|
Multiline and multiple equations | % Multiline -- Easiest is to use multiline, best is to use IEEEeqnarray
\begin{multline}
a + b + c + d + e + f + g + h + i
\\
= j + k + l + m + n
\end{multline}
% Multiple equations - Easiest is to use \begin{align} if NO line too long
\begin{align}
a & = b + c \\
& = d + e
\end{align}
% Multiple equations - ... but best is to use IEEEeqnarray (AVOID \begin{eqnarray} !!!)
% See also commands (\begin{IEEEeqnarray*}, \IEEEyesnumber, \IEEEyessubnumber)
% ... also to group several blocks of equations beside each other
% (source: The not so short introduction to LaTeX)
\usepackage[retainorgcmds]{IEEEtrantools}
\begin{IEEEeqnarray}{rCl}
a & = & b + c
\\
& = & d + e + f + g + h + i + j + k \nonumber\\
&& +\: l + m + n + o
\\
& = & p + q + r + s
\end{IEEEeqnarray}
\begin{IEEEeqnarray}{rCl}
\IEEEeqnarraymulticol{3}{l}{
a + b + c + d + e + f + g + h
}\nonumber\\ \quad
& = & i + j
\\
& = & k + l + m
\end{IEEEeqnarray}
|
Big-O | % Source: http://tex.stackexchange.com/questions/30872/command-for-big-omega
% Negative space fix from http://tex.stackexchange.com/questions/40829/equation-using-left-brackets-inserts-unwanted-space
% Commented sol has fixed size bracket but does not require negative space trick
% \newcommand{\BigO}[1]{\ensuremath{\operatorname{O}\bigl(#1\bigr)}}
\newcommand{\BigO}[1]{\ensuremath{\operatorname{O}\!\left(#1\right)}}
% ... OR ...
\newcommand{\BigO}[1]{\ensuremath{\operatorname{\mathcal{O}}\!\left(#1\right)}}
|
XeLaTeX
LaTeX | XeLaTeX |
---|---|
\usepackage{inputenc}
\usepackage{fontenc}
\usepackage{textcomp}
\usepackage[languageA]{babel}
|
Save file as utf-8 \usepackage{polyglossia}
\setdefaultlanguage[babelshorthands]{languageA}
\usepackage[Ligatures=TeX]{fontspec} % To enable --, ---, '', ``, !`, ?`, ,,, <<, >>
|
Templates
Smallest
\documentclass{article}
\begin{document}
Small is beautiful.
\end{document}
\documentclass[options]{class}
takes optional paramters options, and a mandatory document class. See manual for reference.
3-columns
Example of 3-column document, minimum margin, no page numbering (see [7])
\documentclass[a4paper]{article}
% Specify paper size univocally (for pdf output)
\special{papersize=210mm,297mm}
% Set minimum margin using package geometry
\usepackage[a4paper,landscape,top=1cm, bottom=1cm, left=0.5cm, right=1cm]{geometry}
% To support 3-column document, color and highlighting
\usepackage{multicol,color,soul}
% Remove any footer / header (page numbers...)
\pagestyle{empty}
\begin{document}
\begin{multicols}{3}
Some text here\par
Some more text there\par
And not anymore\par
\end{multicols}
\end{document}
Realistic Journal Article
\documentclass[a4paper,11pt]{article}
% define the title
\author{H.~Partl}
\title{Minimalism}
\begin{document}
% generates the title
\maketitle
% insert the table of contents
\tableofcontents
\section{Some Interesting Words}
Well, and here begins my lovely article.
\section{Good Bye World}
\ldots{} and here it ends.
\end{document}
Layout and Typesetting
- Maintain the relation 1 paragraph = 1 thought across the document.
- English requires longer space after the dots terminating a sentence (see
\@
); French does not (see\frenchspacing
}. - Add footnote after the word or sentence they refer to (i.e. after the comma or periodrelated to a sentence after the terminating dot.
- Avoid ligatures crossing morpheme boundary in a composite word, like shelfful ([8])
- Use ` and ' or `` and as quotation marks in English (or << and >> in French)
- Use the correct dash for each use (X-rated, page 13--67, yes---or no?, $-1$)
- Use
\dots{}
instead of\dots
to add a space after the dots:
This is the end\dots Bye! # Bad This is the end\dots{} Bye! # Good
- Use the correct semantic
\dotsx
command, depending on context:
We have the series $A_1,A_2,\dotsc$, % for comma list
the sum $A_1+A_2+\dotsb$, % for binary op
the orthogonal product $A_1A_2\dotsm$, % for multiplication dots
the infinite integral $$\int_{A_1}\int_{A_2}\dotsi$$. % for dots with integrals
- Use roman style for 'd' in the differential:
\newcommand{\ud}{\,\mathrm{d}}
\begin{equation*}
\int_a^b f(x)\ud x
\end{equation*}
- Use
\textsubscript{}
or\textsuperscript{}
for subscripts our superscripts outside math (like CO2 or 4th). The preferred option for ordinals in mathematics texts (or even english) seems to use$n$th
or$n$-th
(like nth or n-th) [9], [10], [11]. Yet another option is$n^{\text{th}}$
(with amsmath package). Finally, there is the package nth that can render ordinal with\nth{4}
but it only works with numbers.
The $4$th, or the $4$-th, or the $4^{\text{th}}$ or the $4^{\text{\tiny{th}}}$ or the $4$\textsuperscript{th} or \nth{4}?
- Cut long line by adding a
%
at the cut to avoid LaTeX adding unwanted space where the cut occurs:
\State $u \gets (v_i - x)\cdot C_i \bmod \rsamod_i$, $x \gets x + u \cdot% This comment will prevent LaTex adding space
\prod_{j=1}^{i-1}\rsamod_j$
Examples
__MATHJAX_DOLLAR__
- usual conventions
- $\ln x$ is the natural logarithm of $x$; that is, the logarithm of $x$ to the base $e$.
- $\lg x$ is the logarithm of $x$ to the base $2$.
- bitsize
- A $n$-bit integer $N$ ... we know the high order $(1/4+c)(log_2 N)$ bits of P ... $\lceil log_2 N \rceil$-bit integer
Tips / How-to
Quick debug
- Check syntax rapidly by using package syntonly:
\usepackage{syntonly}
\syntaxonly % Comment out this line to produce pages
- Add
draft
to document class to identify layout issues easily:
\documentclass[draft]{article}
Remove sub-sections from header in beamer presentation
Simplest is to use another outer theme (here infolines
):
\documentclass{beamer}
\mode<presentation>
{
\usetheme{Antibes}
% \usetheme{Hannover}
\setbeamercovered{transparent}
% \usefonttheme{structuresmallcapsserif}
% \usefonttheme{structurebold}
\usecolortheme{beaver}
% tree is default outertheme - but infolines is more compact
% \useoutertheme{tree}
\useoutertheme{infolines}
}
% slidenumbering
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{sidebar right}{}
Change vertical alignment
Simply use the [t]
or [c]
modifier (top / center). For frames:
\begin{frame}[t]{The seven permutation army}
% Top-aligned frame
\end{frame}
For columns:
\begin{columns}[t]
\begin{column}{0.35\linewidth}
% 1st top-aligned column
\end{column}
\begin{column}{0.65\linewidth}
% 2nd top-aligned column
\end{column}
\end{columns}
How to format BibTex entries and cite sources
- References
- Bibtex package, see example file xampl.bib (entries
@INBOOK
,@BOOK
...). - Available entry types, and mandatory fields (see WP:BibTeX)
- Recommendations
- Common Errors in Bibliographies — John Owens
- Authors
- Make the names in the bibliography match what is printed on the paper. For hyphenated names with the second half uncapitalized (Wu-chun Feng, Wen-mei Hwu), put the hyphen and second half in brackets:
Wu-{chun} Feng, Wen{-mei} Hwu
. - Capitalization in titles
- Follow capitalization as printed on the paper. The bib style should enforce capitalization, not your bibliography. Properly bracket
{}
words in titles that must be capitalized. - Months
- Include the month of publication in your bibliographies.
- Pages
- Always include pages if pages are available.
- Search article in CiteSeerX, and if found, copy bibtex entry.
- For wikipedia article xxx, use the special wikipedia page
Special:Cite/xxx
that generates automatically a bibtex entry(eg. Special:Cite/Continued_fraction) - The simplest solution for URLs is to use the
howpublished
field [12] [13].
howpublished = {\url{http://en.wikipedia.org/wiki/RSA\_(cryptosystem)}},
- Other alternative are to use more modern styles with support of url and
url
field, or use biblatex.
- Use curly brackets
{}
when necessary: keep word together in author fieldauthor = Template:RSA Laboratories
,protect uppercase words{UPPERCASE}
, capitalise all significant words, to allow for bibliography styles that want this [14]
author = {{RSA Laboratories}}
title = {Pascal, {C}, {Java}: {Were} they all Conceived in {ETH}?}
When citing sources:
- Don't use bracketed numbers as word:
Foo showed that bar~\cite{Foo:2000:BAR}
Foo showed that bar~\shortcite{Foo:2000:BAR} % +++ BETTER - Avoid name repeat
In \cite{Foo:2000:BAR}, Foo shows that bar. % !!! BAD
- This requires to add in your document, in case the bibtex style does not support it
\providecommand{\shortcite}[1]{\cite{#1}}
- Use
~
to prevent break before citation and group several citations together using a comma:
text text text~\cite{Foo:2000:BAR}
\cite{AuthorOne:2000:ABC,AuthorTwo:2002:DEF}
\cite{AuthorOne:2000:ABC}\cite{AuthorTwo:2002:DEF} % !!! BAD !!!
- Convert .ris to .bib — Install package cb2bib and bibutils, then
/usr/share/cb2bib/c2btools/ris2bib 1996-EUROCRYPT-016.ris output.bib
- Software
- Referencer — a GNOME application to organise documents or references, and ultimately generate a BibTeX bibliography file.
Source code listing
See package minted or listings above.
Fix horizontal alignment
- Use
\rlap
and\phantom
. Note that\rlap
does not work in math mode, so we apply a workaround (better solution here)
$\crtCp \gets \rsacipher \bmod \rsap$
{\rlap{$\crtCq$}}$\phantom{\crtCp} \gets \rsacipher \bmod \rsaq$
- Use
\array
, and play with[pos]
option for vertical alignment in the paragraph, and@{}
to suppress inter-column space:
$\begin{array}[t]{@{}r@{}l}
\crtCp &\ \gets \rsacipher \bmod \rsap \\
\crtCq &\ \gets \rsacipher \bmod \rsaq
\end{array}$
- Fix unwanted space when using
\left ... \right
. Insert negative space\!
(see [15] for better solution)
\newcommand{\BigO}[1]{\ensuremath{\operatorname{O}\!\left(#1\right)}}
Troubleshoot
- LaTeX Error
- Cannot determine size of graphic (no BoundingBox)
- LaTeX does not find the BoundingBox information which is necessary to produce the .dvi file. A way to fix this is either to edit the graphic to add the bounding box information, or to use pdflatex to produce directly a .pdf file.
- Missing table of content (file *.toc not found)
- This happens when the command \tableofcontents is used in the document, but LaTeX did not produce yet a table of content file. The .toc file is produced at the first invocation. To solve this, just run LaTex a second time:
pdflatex mypresentation.tex # produce a pdf without toc, and a toc file
pdflatex mypresentation.tex # produce a pdf with toc generated in the previous pass
- "seac" character deprecated in Type 2 charstring
- We get the following error from XeTeX.
** WARNING ** "seac" character deprecated in Type 2 charstring. ** ERROR ** Type2 Charstring Parser: Parsing charstring failed: (status=-1, stack=5) Output file removed.
- This happens when using OpenType fonts (OTF) with accented characters (even i counts as accented!).
- The possible fixes are either to use another font, convert the font to TTF, or fix the buggy OTF.
- Command \sups already defined.
- Occurs when compiling with
xelatex
. See file /usr/share/texmf/tex/latex/tipa/tipa.sty, line 478. - This is apparently a conflict between tipa and fontspec in TeXLive2012 (TeXLive2009 seems ok, see [16])
- "Underfull \hbox (badness 10000) in paragraph at lines X--Y" in bibliography with url
- Add code below to preamble. This LaTeX to allow huge badness when using sloppy command (from [17])
\usepackage{etoolbox}
\apptocmd{\sloppy}{\hbadness 10000\relax}{}{} % To avoid warning in bibtex entries with urls
- Alternatively, simply increase
hbadness
before bibliography section:
\hbadness 10000 % To avoid warning in bibtex entries with urls
\bibliography{ext}
- "Missing elsarticle.cls"
- Install package texlive-publishers to get elsarticle.cls (since TeXLive 2012 — was part of texlive-latex-extra in TeXLive 2009).
- "auto expansion is only possible with scalable fonts" (when using microtype and fourier (aka utopia) package)
- We get the following message when compiling with
pdflatex
:
[1{/home/beq06659/.texmf-var/fonts/map/pdftex/updmap/pdftex.map} ! pdfTeX error (font expansion): auto expansion is only possible with scalable fonts. \AtBegShi@Output ...ipout \box \AtBeginShipoutBox \fi \fi l.105
- The error is because pdftex.map is located in user's profile and is not up-to-date [18]. Update pdftex.map with:
updmap # Update pdftex.map
- hyperref — Failed to convert input string to UTF16
We get this warning when using package hyperref, with option unicode
:
** WARNING ** Failed to convert input string to UTF16...
The solution is to add option pdfencoding=auto
[19]:
\usepackage[unicode=true,pdfencoding=auto]{hyperref}
Importing MS Visio Graphics in LaTeX
Method 1: Using OpenOffice Draw
This procedure creates from a Visio drawing, a PDF file that has the correct page dimension in order to be directly imported in a LaTeX document. This procedure requires to have OpenOffice Draw installed.
- In Visio, File → Save As, select type Enhanced Metafile (.emf), enter a file name, click Save.
- (Using intermediate .emf is less convenient but gives better results than Paste Special as GDI object, which sometimes modify the pasted object)
- In OpenOffice Draw, Open the newly saved file, Select the drawing with the mouse, and then go to menu File → Export.
- Check the box Selection, select format EPS - Encapsulated PostScript (.eps), save the file.
- Press OK, to accept all default options (no preview, Level 2, Grayscale, no compression)
- In a shell, type the LaTeX command
epstopdf <filename.eps>
which will create a file <filename.pdf> with the correct page size.
- Limitations
- Some line formats are not correctly rendered by OpenOffice Draw when exporting to EPS format.
Method 2: Using Custom PostScript Page Size
This procedure can be used to solve problem in the 1st method where some line formats are not correctly rendered in the EPS. This procedure requires to have a PDF printer installed, such as PrimoPDF.
- In Visio, select the drawing to print, and copy-paste it into a new document.
- Go to menu File → Page Setup
- Go to Page Size panel
- Select Size to fit drawing contents, and note the page size as computed by Visio
- Go to Print Setup panel
- Click on Printer Paper Setup
- Click on Printer...
- Select the PDF printer, and click on Properties...
- Click on Advanced...
- For Paper size, select PostScript Custom Page Size, then click on Edit Custom Page Size
- Select unit Millimeter, and then in Width and Height, enter the same size as computed by Visio, plus 1 or 2mm.
- Click Ok buttons until back in the Print Setup dialog. Set Left, Right, Top and Bottom margin to be 0mm, and select Center horizontally and Center vertically.
- If necessary, move the drawing so that it fits perfectly in the middle of the page.
- Print the document.
The result is a PDF document with the best output quality and the correct dimension.
- Limitations
- Sometimes text police are rasterized.
Method 2bis: Using Visio 2007
- Go to menu File → Page Setup
- Go to Page Size panel
- Select Size to fit drawing contents
- Go to menu File → Publish as PDF or XPS
Method 2ter: Using Visio 2010
- Force page margin to 0 in, as explained in [20]. Assuming you already have the developer tab in the Ribbon:
- On the Developer tab, click Show ShapeSheet, and then click Page.
- In the Print Properties section of the ShapeSheet, set the following values to 0:
- PageLeftMargin
- PageRightMargin
- PageTopMargin
- PageBottomMargin
- On the Design tab, click Size and then Fit to drawing.
- On the File tab, select Save As, and select .pdf as file type.
Method 3: Using Postscript printer and Perl script
This method is explained here.
- Install the Adobe Generic Postscript Driver.
- Configure the printer to use EPS, i.e. right click on the printer → Printer Preferences... → click Advanced button → open Document Options → PostScript Options → Under PostScript Output Option, select "Encapsulated PostScript (EPS)".
- In Visio, print your drawing to the postscript printer.
- The bounding box is incorrectly set to the page size. To fix it, use the perl script TightBoundingBox.pl, also copied below (requires gs command from cygwin).
# usage: perl TightBoundingBox.pl <file.eps>
# calculates a tight bounding box (using the 'gs' command) and sets that bounding box into <file.eps>. This is useful where file.eps was created from Visio by printing to the Adobe Generic Postscript Printer into <file.eps>
$inputFileName=$ARGV[0];
# first, find bbox dimensions
$bbox="";
#-sOutputFile=temp_file.bbox
open(GS,"gs -dNOPAUSE -dBATCH -sDEVICE=bbox -sOutputFile=- $inputFileName 2>&1 |");
while (<GS>) {
chop;
if (/^\%\%BoundingBox: (.*)/) {
$bbox=$1;
}
}
close(GS);
#print $bbox;
# now substitute this into file
$tempFileName="temp_file.eps";
system "cat $inputFileName | tr -d \"\r\" > $tempFileName";
open(IN,"$tempFileName");
#open(OUT,">t2.eps"); # don't clobber the input, just for testing
open(OUT,">$inputFileName");
while (<IN>) {
chop;
$gotBbox=0;
if (/^\%\%(.*)BoundingBox: .*/) {
print OUT "%%"."$1BoundingBox: $bbox\n";
}
else {
print OUT "$_\n";
}
}
close(IN);
close(OUT);
Import Inkscape graphics
Importing Inkscape + LaTeX
See SVG-Inkscape, in particular the guide to include Inkscape graphics with LaTeX.