TeX - LaTeX Asked by stephank on April 9, 2021
I just learned to plot tables with pgfplottables and it feels very nice and smooth. Here is my Code example:
documentclass[14pt]{book}
usepackage{pgfplots}
usepackage{pgfplotstable}
usepackage{amsmath}
usepackage{booktabs}
begin{document}
begin{center}
pgfplotstableread{
X C1 C2 C3 C4
$A$ 1 1 1 1
$B$ 1 1 1 1
$C$ 1 1 1 1
$D$ 1 1 1 1
}testdata
pgfplotstabletypeset[
every head row/.style={
before row={toprule
& multicolumn{2}{c}{textbf{table}} cmidrule{2-3}},
after row=midrule},
every last row/.style={after row=bottomrule},
columns/X/.style={string type, column name={test},column type/.add={}{|}},
columns/C1/.style={string type, column name={$a$}},
columns/C2/.style={string type, column name={$b$}},
columns/C3/.style={string type, column name={$c$}},
columns/C4/.style={string type, column name={$d$}},
columns={X, C1,C2,C3,C4},
]testdata
end{center}
end{document}
My question is about the line
columns/X/.style={string type, column name={test},column type/.add={}{|}},
It gives me a line at the right place, but the rule breaks when it reaches the horizontal line right under "X a b c d" and it doesn’t stop there but also implements a rule left to "table".
Is there a possibility to stop it right besides of $X$ without breaking when it passes the horizontal line?
Thank you!
Not sure if this is the output you're interested in, but by adding multicolumn{1}{c}{}
you can shorten the vertical line. In the following example, I also replaced some of the booktabs
lines with hline
and cline
in order to avoid gaps around the intersections of horizontal and vertical lines.
documentclass{book}
usepackage{pgfplots}
usepackage{pgfplotstable}
usepackage{amsmath}
usepackage{booktabs}
begin{document}
begin{center}
pgfplotstableread{
X C1 C2 C3 C4
$A$ 1 1 1 1
$B$ 1 1 1 1
$C$ 1 1 1 1
$D$ 1 1 1 1
}testdata
pgfplotstabletypeset[
every head row/.style={
before row={toprule
multicolumn{1}{c}{} & multicolumn{2}{c}{textbf{table}} cline{2-3}},
after row=hline},
every last row/.style={after row=bottomrule},
columns/X/.style={string type, column name={test},column type/.add={}{|}},
columns/C1/.style={string type, column name={$a$}},
columns/C2/.style={string type, column name={$b$}},
columns/C3/.style={string type, column name={$c$}},
columns/C4/.style={string type, column name={$d$}},
columns={X, C1,C2,C3,C4},
]testdata
end{center}
end{document}
Correct answer by leandriis on April 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP