Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to vertically align these nested tabulars

7 views
Skip to first unread message

Pander

unread,
Mar 15, 2011, 8:14:23 AM3/15/11
to
Hi all,

How can I vertically align these text to the top for these nested
tabulars?

\documentclass{article}
\usepackage{multirow}
\begin{document}

\begin{tabular}{ll}\hline
qwer&\multirow{4}{*}{\begin{tabular}{p{4cm}@{}}asdf sa asdsadff
sadfsadf asfds adsadf sdaasasdf\vfill\end{tabular}}\\
qwer&\\
qwer&\\
qwer&\\\hline
\end{tabular}

\end{document}

Thanks,

Pander

GL

unread,
Mar 15, 2011, 8:48:22 AM3/15/11
to

And though my recommandations, you continue. May be I was not clear :

* NEVER NEVER NEVER USE MULTIROW *

Solution: divide you cells according to what a tabular is:

\begin{tabular}{ll} \hline
\begin{tabular}[t]{c}
qwer \\
qwer \\
qwer \\
qwer
\end{tabular}
&
\begin{tabular}[t]{p{4cm}@{}} asdf sa asdsadff
sadfsadf asfds adsadf sdaasasdf
\end{tabular}
\end{tabular}

>
> Thanks,
>
> Pander

Lars Madsen

unread,
Mar 15, 2011, 8:55:05 AM3/15/11
to
GL wrote:
> Le 15/03/2011 13:14, Pander a �crit :

>> Hi all,
>>
>> How can I vertically align these text to the top for these nested
>> tabulars?
>>
>> \documentclass{article}
>> \usepackage{multirow}
>> \begin{document}
>>
>> \begin{tabular}{ll}\hline
>> qwer&\multirow{4}{*}{\begin{tabular}{p{4cm}@{}}asdf sa asdsadff
>> sadfsadf asfds adsadf sdaasasdf\vfill\end{tabular}}\\
>> qwer&\\
>> qwer&\\
>> qwer&\\\hline
>> \end{tabular}
>>
>> \end{document}
>
> And though my recommandations, you continue. May be I was not clear :
>
> * NEVER NEVER NEVER USE MULTIROW *
>

and what exactly should people who insist on writing entries similar to
HTML rowspan do instead?

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

GL

unread,
Mar 15, 2011, 10:08:51 AM3/15/11
to
Le 15/03/2011 13:55, Lars Madsen a écrit :
> GL wrote:
>> Le 15/03/2011 13:14, Pander a écrit :
>>> Hi all,
>>>
>>> How can I vertically align these text to the top for these nested
>>> tabulars?
>>>
>>> \documentclass{article}
>>> \usepackage{multirow}
>>> \begin{document}
>>>
>>> \begin{tabular}{ll}\hline
>>> qwer&\multirow{4}{*}{\begin{tabular}{p{4cm}@{}}asdf sa asdsadff
>>> sadfsadf asfds adsadf sdaasasdf\vfill\end{tabular}}\\
>>> qwer&\\
>>> qwer&\\
>>> qwer&\\\hline
>>> \end{tabular}
>>>
>>> \end{document}
>>
>> And though my recommandations, you continue. May be I was not clear :
>>
>> * NEVER NEVER NEVER USE MULTIROW *
>>
>
> and what exactly should people who insist on writing entries similar to
> HTML rowspan do instead?
>

\halign is not the same as <table>...</table> and not designed to span
rows. And pdf is not html. Hopefully! However, it is *always* possible
to get a tabular where rows look like if they were spanned, by dividing
the cells correctly.

|---------------------------------------------------|
| | |
| |-------------------------|
| | |
|-------------------------|-------------------------|

This is absolutely not a multirow in the sense of \halign, because
\halign does not know what multirow is, and multirow package provides
a (possibly tempting) "fake" code based on the idea that the
height/depth of the rows are multiple of the \@arstrutbox dimensions.

For \halign:
.this is a table that contains one row that contains 2 cells.
.The first cell contains whatever you want
.The second contains a \halign that contains two rows, each one
has 1 cell.


A bit more complex :

|---------------------------------------------------|
| | |
| |-------------------------|
| | |
| |-------------------------|
| | |
|-------------------------| |
| | |
|-------------------------|-------------------------|

. this is a table that contains one row that contains 2 cells.
. the first cell contains a \halign that contains two rows, each
one has 1 cell
. the second cell contains \halign that contains 3 rows, each one
has 1 cell

Step by step it is always possible to divide each rectangle.
To control the height/depths, tabu will be more powerfull than
tabular, but even with tabular you can make such a table easily
provided you don't change the font size too much:

Here is how \halign works:

% ------------------------------------------------------
\documentclass [a4paper]{article}

\usepackage {array}

\begin{document}

\tabcolsep =0pt
\begin{tabular}{|*2{>{\tabcolsep=12pt}c|}} \hline
\begin{tabular}{c}
\rlap{\begin{tabular}{c} \\ \\ \\ \end{tabular}}%
One \\ \hline
two
\end{tabular}
&
\begin{tabular}{c}
One \\
Two \\ \hline
{\large Three} \rlap{\begin{tabular}{c}\\ \\\end{tabular}}%
\end{tabular} \\ \hline
\end{tabular}
\end{document}\endinput
% -----------------------------------------------------

no measure, perfect alignment,
even if you change the margin, the font, \mag, whatever you
want to change...

Regards.

Lars Madsen

unread,
Mar 15, 2011, 10:16:51 AM3/15/11
to

and a normal user should understand this?

Philipp Stephani

unread,
Mar 15, 2011, 10:30:20 AM3/15/11
to
Lars Madsen <dal...@RTFMSIGNATUREimf.au.dk> writes:

>> And though my recommandations, you continue. May be I was not clear :
>>
>> * NEVER NEVER NEVER USE MULTIROW *
>>
>
> and what exactly should people who insist on writing entries similar to HTML
> rowspan do instead?

Use ConTeXt? (SCNR)

--
Change “LookInSig” to “tcalveu” to answer by mail.

GL

unread,
Mar 15, 2011, 10:38:15 AM3/15/11
to

If he wants to make "non regular" tabulars: yes.
I fear there is no other solution with \halign.
It's not difficult to provide a \reserveheight command
with \erows from makecell, which is buggy by the way
(does not work with one column tabulars - but no matter):


% ----------------------------------------------------
\documentclass [a4paper]{article}

\usepackage {array,makecell}

\begin{document}

\def\reserveheight #1{%
\rlap{\begin{tabular}{ll} \erows [\\]1{#1}\end{tabular}}}


\tabcolsep =0pt
\begin{tabular}{|*2{>{\tabcolsep=12pt}c|}} \hline
\begin{tabular}{c}

\reserveheight{3} One \\ \hline

two

\end{tabular}
&
\begin{tabular}{c}
One \\
Two \\ \hline

\reserveheight{2} {\large Three}

\end{tabular} \\ \hline
\end{tabular}
\end{document}\endinput

% --------------------------------------------------------

Otherwise, you can keep cooking with \multirow, obwohl das ist
kein TeX tabelle ...

Regards.

0 new messages