Simple question that I couldn't find an answer to anywhere: I am using \cline
to create discontinued lines in my tables. Sometimes I want to have a line just spanning over one column rather than multiple columns. \cline
only works for more than one column. What is the alternative?
[Tex/LaTex] Line under one column
rulestables
Related Solutions
I think that the only feasible option is to split the data into 2n parts:
- first part, columns 1-15, rows 1-24,
\newpage
- second part, columns 16-30, rows 1-24,
\newpage
- third part, columns 1-15, rows 24-48,
\newpage
- fourth part, columns 16-30, rows 24-48,
\newpage
- ...
Twenty-four rows is just to put some number. If the data and the header row are homogeneous in height, they should align perfectly.
For the caption, it can go on the left page, but I suggest to set it into a \vbox
with prescribed height:
\newcommand{\mycaption}[1]{\vbox to 3\baselineskip{
\vfill\captionof{table}{#1}\vfill}}
where 3 is a number bigger than the number of lines in the caption. For the right page you can say
\newcommand{\fakecaption}{\vbox to 3\baselineskip{}}
and insert \fakecaption
after the \newpage
; \captionof
requires the caption package.
The margins can be overridden either with \newgeometry
of the geometry package or simply by inserting each "subtable" inside \makebox[\textwidth]{}
.
A possible implementation
\documentclass[a4paper,twoside]{book}
\usepackage{caption}
\newlength{\leftcaptionht}
\newsavebox{\tablebox}
\newcommand{\lefttable}[1]{%
\setbox\tablebox=\vbox{\medskip\captionof{table}{#1}}
\setlength{\leftcaptionht}{\ht\tablebox}%
\box\tablebox}
\newenvironment{doubletable}
{\newpage\ifodd\value{page}\null\newpage\fi\centering}{\newpage}
\newenvironment{widetabular}
{\begin{lrbox}{\tablebox}\begin{tabular}}
{\end{tabular}\end{lrbox}\makebox[\textwidth]{\usebox{\tablebox}}}
\newcommand{\righttable}{\newpage\vbox to\leftcaptionht{}}
\begin{document}
text
\begin{doubletable}
\lefttable{This is a caption}
\begin{widetabular}{ll}
a column long enough to go over & a column long enough to arrive over the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}
\righttable
\begin{widetabular}{ll}
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}
\end{doubletable}
\begin{doubletable}
\lefttable{This is a caption that occupies more than one line and so has to wrap, so that we
can show that the alignment is correct}
\begin{widetabular}{ll}
a column long enough to go over & a column long enough to arrive over the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}
\righttable
\begin{widetabular}{ll}
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}
\end{doubletable}
\end{document}
If you want a caption on the right pages, it's sufficient to define \righttable
differently:
\newcommand{\righttable}{\newpage\vbox to\leftcaptionht{\medskip
\noindent(Table \thetable{} (continued)}}
(or something similar).
The suggestion is to add rows to the tables until they fit on the page and then start a new pair.
In answer to your question about wrapping text contained within a \multirow
, you can put the contents <stuff>
in a paragraph box \parbox{<len>}{<stuff>}
where you specify the width <len>
:
\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}% http://ctan.org/pkg/multirow
\begin{document}
\begin{tabular}{cccc}
\toprule
& & \multicolumn{2}{c}{Logic of rule adoption} \\
\cmidrule{3-4}
& & Logic of & Logic of \\
& & consequences & appropriateness \\
\midrule
\multirow{2}{*}{\parbox{4cm}{Principal actor in rule adoption process}} & EU-driven & External incentives model & Social learning model \\
& CEE-driven & Lesson-drawing model & Lesson-drawing model \\
\bottomrule
\end{tabular}
\end{document}
However, this is still very wide in terms of your document specifications (12pt,a4paper
). So, here's perhaps a better table layout and some margin adjustments (using geometry
):
\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage[margin=3cm]{geometry}% http://ctan.org/pkg/geometry
\begin{document}
\noindent\begin{tabular}{ccc}
\toprule
& \multicolumn{2}{c}{Logic of rule adoption} \\
\cmidrule{2-3}
\parbox{0.3\linewidth}{\centering Principal actor in rule adoption process} &
\parbox{0.3\linewidth}{\centering Logic of consequences} &
\parbox{0.3\linewidth}{\centering Logic of appropriateness} \\
\midrule
EU-driven & External incentives model & Social learning model \\
CEE-driven & Lesson-drawing model & Lesson-drawing model \\
\bottomrule
\end{tabular}
\end{document}
Note the \noindent
to avoid a paragraph indent, otherwise it will push the table over to the right, over the text (right) margin.
Best Answer
\cline{1-1}
,\cline{2-2}
and so on to underline only first, second and so on column.