Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to combine this answer Compile a LaTeX document into a PNG image that's as short as possible with my answer Add column in a table

But the pdflatex -shell-escape table.tex ignores linebreaks and the 3 tables are horizontally aligned and not vertically.

table.tex

\documentclass[convert]{standalone}
% \documentclass{article}

\usepackage{booktabs} % for nice lines
\usepackage{siunitx}  % nice numbers and units and 'S' in table
\usepackage{multirow} % enable \multirow command

\begin{document}
short answer to your question:\\
\begin{tabular}{|c|c|S|}
\hline
Genre & Name & {Weight}\\\hline
Humain & Aragorn & 102 \\\hline
\multirow{4}{*}{Hobbit}&Frodon & 32.1\\\cline{2-3}
    &Sam & 3.2 \\\cline{2-3}
    &Peregrin & 2.232\\\cline{2-3}
    &Meriadoc & 23 \\\hline
Elfe&Legolas & 34.5 \\\hline
\end{tabular}\\[1cm]


You can also use the power of booktabs and siunitx:\\
\begin{tabular}[ht]{l c S} % alignment l = left, c = centre, S = at decimal - needs siunitx
\toprule
Genre&Name& {Weight}\\  % protect non numbers with {} in S columns
\midrule
Elfe&Legolas & 34.5\\
Dwarf&Peter & 103.31\\
\bottomrule
\end{tabular}\\[1cm]

And combine that with your table:\\
\begin{tabular}{c c S}
\toprule
Genre & Name & {Weight}\\\midrule
Humain & Aragorn & 102 \\\midrule
\multirow{4}{*}{Hobbit}&Frodon & 32.1\\\cline{2-3}
    &Sam & 3.2 \\\cline{2-3}
    &Peregrin & 2.232\\\cline{2-3}
    &Meriadoc & 23 \\\midrule
Elfe&Legolas & 34.5 \\
\bottomrule
\end{tabular}


\end{document}
share|improve this question
You have to pass the varwidth option to the class. – egreg Nov 14 '12 at 18:36

1 Answer

up vote 6 down vote accepted

By default the standalone class doesn't make paragraphs. However, with the varwidth option it does; so

\documentclass[varwidth,convert]{standalone}

will do what you want, adjusting the width to the longest line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.