I need to copy a table from a pdf file to my LaTeX document. I know I have to do it by hand but still don't understand how to create a table with LaTeX.
[Tex/LaTex] Create a table with LaTeX
tables
Related Solutions
If the entire content of your tables, including the caption, needs to be set in typewriter or monospaced font, the following code (to be inserted in your document's preamble) will do the font switching for you transparently:
\makeatletter
\renewenvironment{table}%
{\renewcommand{\familydefault}{\ttdefault}\selectfont
\@float{table}}
{\end@float}
\makeatother
On the other hand, if you want only the "tabular" portion of a table (but not the caption) to be typeset in typewriter font, you're probably best off (i) inserting the command \texttt{%
, on a line by itself, right before the \begin{tabular}{...}
line and (ii) adding a solitary closing brace, }
, immediately after the \end{tabular}
instruction. Happy TeXing!
Dan's answer is very good and teaches how to build such a table from scratch. However, if you have several tables following the same patterns it might be better to have a higher level syntax for them.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\parametertable}{mmm}
{
\seq_set_split:Nnn \l_ella_parametertable_parameters_seq { \\ } { #3 }
\begin{tabular}{|l|p{1in}|p{1in}|}
\hline
Name & \multicolumn{2}{l|}{#1} \\
\hline
Type & \multicolumn{2}{l|}{#2} \\
\hline
Parameters &
\seq_use:Nn \l_ella_parametertable_parameters_seq { \\ \cline{2-3} & }
\\
\hline
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\parametertable{Alice}{Client}{
Param1 & Value \\
Param2 & Value \\
Param3 & Value
}
\end{document}
The advantage to such an approach will be evident when you'll decide that, after all, those rules are annoying and you'll want to switch to booktabs
. Just modifying the main command in a few details, all your similar tables will change format.
\documentclass{article}
\usepackage{xparse}
\usepackage{booktabs}
\ExplSyntaxOn
\NewDocumentCommand{\parametertable}{mmm}
{
\seq_set_split:Nnn \l_ella_parametertable_parameters_seq { \\ } { #3 }
\begin{tabular}{lp{1in}p{1in}}
\toprule
Name & \multicolumn{2}{l}{#1} \\
\midrule
Type & \multicolumn{2}{l}{#2} \\
\midrule
Parameters &
\seq_use:Nn \l_ella_parametertable_parameters_seq { \\ & }
\\
\bottomrule
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\parametertable{Alice}{Client}{
Param1 & Value \\
Param2 & Value \\
Param3 & Value
}
\end{document}
Note that the document code has not changed in any way.
Best Answer
Here, the figure labels are printed as
Table x.y
wherex
is the section number andy
is a table number within sectionx
.Update
Another way of creating the table is using the
S
column fromsiunitx
;(Personally, I prefer this method.)