LaTeX

How to fix LaTeX missing footnotes in tabular environment

Problem:

You have LaTeX code with a \footnote inside a \tabular like this:

\documentclass{scrartcl}

\begin{document}
\begin{tabular}{p{2cm}|p{2cm}|}
\textbf{Column A\footnote{This is a footnote!}} & \textbf{Column B}\\
1 & 2\\
3 & 4\\
\end{tabular}
\end{document}

but LaTeX/PDFLaTeX is not showing any of the footnotes you declared inside the \tabular environment.

Solution:

Use this code just after your \documentclass declaration:

\usepackage{footnote}
\makesavenoteenv{tabular}

Then recompile your LaTeX code. The footnotes inside your tabular should now appear as expected.

Note that if you are using other environments than \begin{tabular} you might need to add more \makesavenoteenv declarations for the correct environments. The tabularx environment from the tabularx package works with footnotes out-of-the box without any additional packages!

 

Posted by Uli Köhler in LaTeX

How to fix LaTeX \glqq or \grqq error ‘Undefined control sequence’

Problem:

You have LaTeX code containing \glqq and/or \grqq like

\documentclass{scrartcl}

\begin{document}
\glqq Test\grqq
\end{document}

but when you try to compile it, you see an error message like this:

! Undefined control sequence.
l.5 \glqq
          Test\grqq
? 

Solution:

In order to use \glqq or \grqq you need to include

\usepackage[ngerman]{babel}

after your \documentclass declaration.

In case you want to use another language, use the correct language specifier instead of ngerman.

Posted by Uli Köhler in LaTeX

How to insert € symbol in LaTeX using UTF8

Note: This is the recommended method for using and other symbols in LaTeX!

In order to insert the symbol into your LaTeX document, first add

\usepackage[official]{eurosym}
\usepackage[utf8x]{inputenc}

to the top of your document, e.g. directly after your \documentclass line.

After that, you can use the normal symbol anywhere in your document like this:

to insert an symbol.

 

 

Posted by Uli Köhler in LaTeX

How to insert € symbol in LaTeX using the eurosym package

Note: This method is no longer recommended and only provided for compatibility reasons! See How to insert Euro symbol in LaTeX using UTF8 for the recommended method instead!

In order to insert the symbol into your LaTeX document, first add

\usepackage[official]{eurosym}

to the top of your document, e.g. directly after your \documentclass line.

After that, you can use

\euro{}

to insert an symbol anywhere in your document.

 

Posted by Uli Köhler in LaTeX

How to reduce page margins in LaTeX using the geometry package

To set or reduce the page margin (white space between the border of the page and the text) you can use the geometry package.

Set margin of all sides to 2cm:

\usepackage[left=20mm, right=20mm, top=20mm, bottom=20mm]{geometry}

To set just the left and right margin to 2cm, use

\usepackage[left=20mm, right=20mm]{geometry}

 

Posted by Uli Köhler in LaTeX

How to convert a DVI file to SVG on the command line

If you want to convert my.dvi to my.svg, use this command

dvi2ps my.dvi | ps2eps - > my.eps && eps2svg my.eps

This produces my.svg – note that if my.svg already exists, eps2svg will create my_1.svg, my_2.svg and so on and will not overwrite my.svg!

You can also use this shell function:

function dviToSVG { dvi2ps "$1" | ps2eps - > "${1%.*}.eps" && eps2svg "${1%.*}.eps" "${1%.*}.svg" ; }

Usage example:

dviToSVG my.dvi # Produces my.svg

 

Posted by Uli Köhler in LaTeX, Linux, Shell

Minimal LaTeX booktabs example

This is a minimal example using the LaTeX booktabs package which you can use & modify to create your own table.

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage[utf8x]{inputenc}

\begin{document} 

\begin{table}[h!]
    \begin{center}
      \caption{Minimal booktabs example.}
      \label{tab:table1}
      \begin{tabular}{l|c|r}
        \toprule % <-- Toprule here
        \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3}\\
        $\alpha$ & $\beta$ & $\gamma$ \\
        \midrule % <-- Midrule here
        A & 10.23 & a\\
        B & 45.678 & b\\
        C & 99.987 & c\\
        \bottomrule % <-- Bottomrule here
      \end{tabular}
    \end{center}
  \end{table}
\end{document}

Render it using

pdflatex booktabs.tex

The table looks like this:

Posted by Uli Köhler in LaTeX

How to fix LaTeX error File `siunitx.sty’ not found on Ubuntu

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

! LaTeX Error: File `siunitx.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Solution

sudo apt -y install texlive-science

This will install, among many other LaTeX files, siunitx.sty.

Posted by Uli Köhler in LaTeX

How to fix LaTeX error File `environ.sty’ not found on Ubuntu

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

! LaTeX Error: File `environ.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Solution

sudo apt -y install texlive-latex-extra

This will install, among many other LaTeX files, environ.sty.

Posted by Uli Köhler in LaTeX, Linux

How to fix LaTeX error Package babel Error: Unknown option `ngerman’ on Ubuntu

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

! Package babel Error: Unknown option `ngerman'. Either you misspelled it
(babel)                or the language definition file ngerman.ldf was not foun
d.

See the babel package documentation for explanation.
Type  H <return>  for immediate help

Solution

sudo apt -y install texlive-lang-german

This will install, among many other LaTeX files, the files for the ngerman language.

Posted by Uli Köhler in LaTeX, Linux

How to fix Ubuntu LaTeX ! I can’t find file `ecrm1200′.

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

kpathsea: Running mktexmf ecrm1200
! I can't find file `ecrm1200'.
<*> ...ljfour; mag:=1; nonstopmode; input ecrm1200
                                                  
Please type another input file name
! Emergency stop.
<*> ...ljfour; mag:=1; nonstopmode; input ecrm1200
                                                  
Transcript written on mfput.log.
grep: ecrm1200.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input ecrm1200' failed to make ecrm1200.tfm.
kpathsea: Appending font creation commands to missfont.log.

! Font T1/cmr/m/n/12=ecrm1200 at 12.0pt not loadable: Metric (TFM) file not fou
nd.
<to be read again> 
                   relax 
l.105 \fontencoding\encodingdefault\selectfont

Solution

sudo apt -y install texlive-fonts-recommended

This will install, among many other LaTeX files, ecrm1200.mf and ecrm1200.tfm.

.

Posted by Uli Köhler in LaTeX, Linux

How to fix LaTeX Error: File `scrartcl.cls’ not found on Ubuntu

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

! LaTeX Error: File `scrartcl.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Solution

sudo apt -y install texlive-latex-recommended

This will install, among many other LaTeX files, scrartcl.cls.

Posted by Uli Köhler in LaTeX, Linux

How to fix KaTeX parse error: KaTeX doesn’t work in quirks mode

Problem:

You’re using KaTeX on a website, but every time you try to render, you encounter the following error message:

Uncaught Error: KaTeX parse error: KaTeX doesn't work in quirks mode.
    at new e (VM697 katex.min.js:1)
    at Object.l [as render] (VM697 katex.min.js:1)
[...]

Solution:

KaTeX requires a valid DOCTYPE declaration on your HTML page, so add this line at the top of your HTML file(s), above <html>

<!DOCTYPE html>

Thanks to @xymostech on GitHub for the original solution in the the KaTeX issue tracker:

Posted by Uli Köhler in Javascript, LaTeX

Fixing LaTeX Unknown option fetbodydiode for package circuitikz

Problem:

You want to compile a LaTeX file containing CircuiTikZ code but you get the following error:

LaTeX Error: Unknown option `fetbodydiode' for package `circuitikz'

Solution:

You have an outdated CircuiTikZ version (fetbodydiode is in TeXLive 2016+).  Depending on your distribution, there are several ways to update CircuiTikZ:

For ubuntu, see this post to update to TeXLive 2016

For other distributions, see this post using tlmgr

Posted by Uli Köhler in LaTeX

Fixing CircuiTikZ Error: I do not know the key ‘/tikz/elmech’

Problem:

You want to compile a LaTeX file containing CircuiTikZ code but you get the following error:

Error: I do not know the key '/tikz/elmech'

Solution:

First, be sure that the circuitikz package is included, i.e. there’s a line like

\usepackage{circuitikz}

in your LaTeX file.

If that is the case, you likely have an outdated CircuiTikZ version (elmech is in TeXLive 2016+).  Depending on your distribution, there are several ways to update CircuiTikZ:

For ubuntu, see this post to update to TeXLive 2016

For other distributions, see this post using tlmgr

Posted by Uli Köhler in LaTeX

Fixing LaTeX Error: File … not found on Debian/Ubuntu

Problem:

You’re using latex or pdflatex to compile a .tex file, but you get an error message similar to this one (the solution will work for any missing file, not just utf8x.def):

! LaTeX Error: File `utf8x.def' not found.

Now you’re wondering which package you need to install

Solution 1: Install everything

This problem can often be fixed once and for all by just installing all packages:

sudo apt-get install texlive-full

However, this pulls in a huge amount of packages and is therefore not recommended for most situations.

Solution 2: Install only required package

You can use apt-file to find the package containing the missing file and install it.

First, update the list of files in all known packages (sudo apt-get install apt-file if required):

sudo apt-file update

You only need to do this once every few months or so, before you use apt-file.

Then, look for the missing file (replace utf8x.def by your missing file):

$ apt-file search utf8x.def
texlive-lang-japanese: /usr/share/texlive/texmf-dist/tex/latex/bxbase/bxutf8x.def
texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def
texlive-luatex: /usr/share/texlive/texmf-dist/tex/lualatex/luainputenc/lutf8x.def

Now it takes some educated guessing which of the three listed packages (texlive-lang-japanese, texlive-latex-extra, texlive-luatex) needs to be installed. In this case, texlive-latex-extrais the correct choice as the other packages list the missing file only in some subdirectory of package (like luainputenc). If in doubt, you can just install all of the listed packages.

Posted by Uli Köhler in LaTeX, Linux