I have a two column table. The first column contains (for eg) name and designation and second column has lots of text. I want the name and designation to stay close but on separate lines. For this I enter them on separate rows. However when I use multirow
on second column, the text from one row starts overlapping text from subsequent rows. How can I avoid text from different rows from overlapping? The following code show some things I have been trying. I was trying to get to the contents formatted as on second page (last 2-3 rows) but want to avoid the text overlap.
\documentclass[oneside]{memoir}
% \usepackage[cm]{fullpage}
% \usepackage{showframe}
% showframe does not show proper frame
\usepackage[margin=0.5in, showframe]{geometry}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{calc}
\usepackage{multirow}
\begin{document}
\newlength{\tablecolwidth}
\setlength{\tablecolwidth}{0.6\textwidth-2\tabcolsep}
\begin{longtable}{@{}lp{\tablecolwidth}@{}}
\caption{Contents}\\
\textbf{Col 1} & \textbf{Col 2} \\
\midrule[0.25ex]
\endfirsthead
\multicolumn{2}{c}{\tablename\ \thetable{}: continued}\\[1ex]
\textbf{Col 1} & \textbf{Col 2} \\
\midrule[0.25ex]
\endhead
\midrule
\multicolumn{2}{r}{Continued \ldots}\\
\endfoot
\bottomrule[0.25ex]
\endlastfoot
Name & \lipsum[2] \\
Designation & \lipsum[1] \\
\midrule
% Contents overflow on right
Name & \multirow{2}{*}{\lipsum[2]} \\
Designation \\
& \lipsum[1] \\
\midrule
% Contents of next row overlap subsequent rows and over flow page boundary
Name & \multirow{2}{\tablecolwidth}{\lipsum[1-2]} \\
Designation \\
& \lipsum[1] \\
\midrule
% Another way of limiting column width but overlap remains
Name & \multirow{2}{*}{\parbox{\tablecolwidth}{\lipsum[2]}} \\
Designation \\
& \lipsum[1] \\
\end{longtable}
\end{document}
Also when I use fullpage
and showframe
, I get incorrect frame. I was able to fix it using geometry
package, but still wondering what the reason for the wrong frame is?
Edit, I was able to get the right formatting this way,
Name & \multirow{1}{*}{\parbox{\tablecolwidth}{\lipsum[2]}} \\
Designation \\ \\ \\ \\ \\ \\ \\
& \lipsum[1] \
However I am still trying to find a better way to do this.
Best Answer
Margins,
showframe
Package
fullpage
does not supportmemoir
. The classmemoir
is more complicate than the standard classes regarding the page layout. It provides additional length\stockwidth
,\stockheight
and another stuff like crop marks, …The additional length
\spinemargin
,\foremargin
,\uppermargin
,\lowermargin
are not supported by packagegeometry
. After the new margins are set, these length have the wrong values. But packageshowframe
/eso-pic
supportsmemoir
and uses some of these length.They can manually be fixed:
But I do not recommend using
geometry
withmemoir
, because the class has its own methods for setting the page layout, e.g.:Tabular
Perhaps you just want to have two
p
-columns, but without the width specification for the first? Then you can use atabular
inside thelongtable
to put the two entries in two lines in the first column: