Add these command line options:
-V geometry:margin=20mm
-V
is short-form for --variable
This will configure the default LaTeX template to use
\usepackage[margin=20mm]{geometry}
Add these command line options:
-V geometry:margin=20mm
-V
is short-form for --variable
This will configure the default LaTeX template to use
\usepackage[margin=20mm]{geometry}
In our previous post on How many bits does an I2C address have? we showed this diagram:
This diagram was made using TikZ using the following source code:
% I2C first byte diagram % Author: Uli Koehler (https://techoverflow.net) \documentclass[tikz, border=1mm]{standalone} \usetikzlibrary{positioning, decorations.pathreplacing, arrows.meta} % Source: https://tex.stackexchange.com/a/24133/45450 \makeatletter \newcommand*{\textoverline}[1]{$\overline{\hbox{#1}}\m@th$} \makeatother \begin{document} \begin{tikzpicture} \node (A6) [draw, minimum height=7mm, minimum width=10mm] {$A_6$}; \node (A5) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A6] {$A_5$}; \node (A4) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A5] {$A_4$}; \node (A3) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A4] {$A_3$}; \node (A2) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A3] {$A_2$}; \node (A1) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A2] {$A_1$}; \node (A0) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A1] {$A_0$}; \node (RW) [draw, minimum height=7mm, minimum width=10mm, right=0cm of A0] {R/\textoverline{W}}; \coordinate[above left=0mm of A6] (AddrLeft); \coordinate[above right=0mm of A0] (AddrRight); \coordinate[below left=0mm of RW] (RWLeft); \coordinate[below right=0mm of RW] (RWRight); \draw[decorate,decoration={brace,amplitude=10pt}, minimum height=9mm] (AddrLeft) -- (AddrRight) node[anchor=south,midway,above=8pt] {I2C address}; \draw[decorate,decoration={brace,amplitude=8pt}, minimum height=6mm] (RWRight) -- (RWLeft) node[anchor=north,midway,below=8pt] {Read/\textoverline{Write} bit}; \end{tikzpicture} \end{document}
and compiled to SVG using this Makefile
– for details, see How to export TikZ graphics as SVG:
%.pdf: %.tex pdflatex $< %.svg: %.pdf pdf2svg $< $@ all: I2CFirstByte.svg
If you have a TikZ graphic, you can use the LaTeX standalone
package to make the page fit the content:
% Minimal TikZ standalone example \documentclass[tikz, border=1mm]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) node [] {My text}; \end{tikzpicture} \end{document}
Assuming you have saved that file as MyDiagram.tex
, you can convert it to a PDF and subsequently convert that PDF to a SVG using
pdflatex MyDiagram.tex pdf2svg MyDiagram.pdf MyDiagram.svg
which will generate this SVG:
Note that the 1mm border around the content is intentional and recommended for most usecases. The background is transparent by default (but has been set to white in HTML on this blogpost to illustrate the extent of the SVG).
You can also use this Makefile template:
%.pdf: %.tex pdflatex $< %.svg: %.pdf pdf2svg $< $@ all: MyDiagram.svg
which allows you to automatically run the commands for one or multiple TeX files.
This example contains a simple TikZ graphic using the standalone
package, i.e. it will be exported to a PDF/DVI where the page just fits the content:
\documentclass[tikz, border=1mm]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) node [draw=black] {My text}; \end{tikzpicture} \end{document}
The result looks like this:
Assuming the file is named MyDiagram.tex
, you can compile it to PDF using
pdflatex MyDiagram.tex
Note that our example contains a 1mm
border by default since this seems to be more suitable for the average usecase than having no border at all. In order to change that, you just need to modify the first line, e.g.
\documentclass[tikz]{standalone} % No border
or
\documentclass[tikz]{standalone, border=5mm} % 5mm border
In TikZ, if you have a node like
\draw (0,0) node [] {My text};
you can add a border around it by using the draw=...
attribute for the node
:
\draw (0,0) node [draw] {My text};
You can also tell TikZ to draw it in blue:
\draw (0,0) node [draw=blue] {My text};
or tell it to draw it dashed:
\draw (0,0) node [draw, dashed] {My text};
You can also make the border thin or thick:
\draw (0,0) node [draw, very thin] {Very thin border}; \draw (0,-1) node [draw, thin] {Thin border}; \draw (0,-2) node [draw, semithick] {Semithick border}; \draw (0,-3) node [draw, thick] {Thick border}; \draw (0,-4) node [draw, very thick] {Very thick border}; \draw (0,-5) node [draw, ultra thick] {Ultra thick border};
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.
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!
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 ?
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
.
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.
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.
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}
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
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:
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)
sudo apt -y install texlive-science
This will install, among many other LaTeX files, siunitx.sty
.
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)
sudo apt -y install texlive-latex-extra
This will install, among many other LaTeX files, environ.sty
.
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
sudo apt -y install texlive-lang-german
This will install, among many other LaTeX files, the files for the ngerman
language.
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
sudo apt -y install texlive-fonts-recommended
This will install, among many other LaTeX files, ecrm1200.mf
and ecrm1200.tfm
.
.
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)
sudo apt -y install texlive-latex-recommended
This will install, among many other LaTeX files, scrartcl.cls
.
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) [...]
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:
You want to compile a LaTeX file containing CircuiTikZ code but you get the following error:
LaTeX Error: Unknown option `fetbodydiode' for package `circuitikz'
You have an outdated CircuiTikZ version (fetbodydiode
is in TeXLive 2016+). Depending on your distribution, there are several ways to update CircuiTikZ:
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'
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: