What Is a Drawing Table Used for
A few initial comments:
-
I'm assuming you're using the
multirowpackage to try to print the multiple columns (you didn't say, but it seems like the natural choice). -
I'd suggest using the
siunitxpackage to align the decimal points in your table. -
The
booktabspackage has some good advice for nice-looking tables in LaTeX in the documentation. I've used it below, but you can remove the dependency by replacing\toprule,\midruleand\bottomrulewith\hline.
As for why the current example isn't compiling:
-
The
tabulardoesn't have enough columns. You've passed the option{|l|l|l|l|}, which is four left-aligned columns with vertical bars between each of them. At its widest, the original table has seven columns, and you need to account for all of them. So this should be changed to something like{|l|l|l|l|l|l|l|}.If you use
siunitx, then use{lSSSSSS}: theSis an option fromsiunitxwhich lines up the decimal points in your data. Feel free to change this back if you don't want to/can't use this package. -
The
multicolumn{6} {c|}takes the Dataset heading and fills six columns with it, then you have three more columns for A, B and C. This means that this row has nine columns overall, which is more than you need.Instead, you want something more like:
\multirow{2}{*}{Dataset} & \multicolumn{2}{c}{A} & \multicolumn{2}{c}{B} & \multicolumn{2}{c|}{C} \\You need to make the final column
c|so that you get the final vertical line at the end. -
In the second row, you skip the first cell (which gets filled by **Dataset* from the previous row), and then fill the rest as normal:
& O.B.R & A.R & O.B.R & A.R & O.B.R & A.R \\If you do use
siunitx, then you need to wrap these in curly braces, so that the period doesn't get read as a decimal point. If you don't, then you get an error because it can't line these numbers up.& {O.B.R} & {A.R} & {O.B.R} & {A.R} & {O.B.R} & {A.R} \\
If we modify your code with these suggestions in mind, we get something like this:
\documentclass{article} \usepackage{multirow} \begin{document} \begin{table} \begin{tabular}{|l|l|l|l|l|l|l|} \hline \multirow{2}{*}{Dataset} & \multicolumn{2}{c}{A} & \multicolumn{2}{c}{B} & \multicolumn{2}{c|}{C} \\ & O.B.R & A.R & O.B.R & A.R & O.B.R & A.R \\ \hline D1 & 2.1\% & 2.1\% & 2.1\% & 2.1\% & 2.1\% & 2.1\% \\ \hline D2 & 11.6\% & 11.6\% & 11.6\% & 11.6\% & 11.6\% & 11.6\% \\ \hline D3 & 5.5\% & 5.5\% & 5.5\% & 5.5\% & 5.5\% & 5.5\% \\ \hline \end{tabular} \end{table} \end{document} and this is the result:
Here's an example that includes siunitx and booktabs (I also put the % sign in the header to ease readability):
\documentclass{article} \usepackage{booktabs} \usepackage{multirow} \usepackage{siunitx} \begin{document} \begin{table} \begin{tabular}{lSSSSSS} \toprule \multirow{2}{*}{Dataset} & \multicolumn{2}{c}{A (\%)} & \multicolumn{2}{c}{B (\%)} & \multicolumn{2}{c}{C (\%)} \\ & {O.B.R} & {A.R} & {O.B.R} & {A.R} & {O.B.R} & {A.R} \\ \midrule D1 & 2.1 & 2.1 & 2.1 & 2.1 & 2.1 & 2.1 \\ D2 & 11.6 & 11.6 & 11.6 & 11.6 & 11.6 & 11.6 \\ D3 & 5.5 & 5.5 & 5.5 & 5.5 & 5.5 & 5.5 \\ \bottomrule \end{tabular} \end{table} \end{document} which compiles to
What Is a Drawing Table Used for
Source: https://tex.stackexchange.com/questions/166263/drawing-multicolumn-table-in-latex
0 Response to "What Is a Drawing Table Used for"
Post a Comment