Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider this document example:

\documentclass[a4paper,draft]{article}

\usepackage{calc}
\usepackage[demo]{graphicx}
\usepackage{tabularx,multirow}

\usepackage{geometry}
\geometry{hmargin=0cm}

\newlength\framewidth
\setlength{\framewidth}{\paperwidth}
\addtolength{\framewidth}{-3cm}

\begin{document}
\centering

\fbox{
\begin{tabularx}{\framewidth}{XXX}
\multirow{3}{0.30\framewidth}{\centering
\includegraphics[width=0.2\textwidth, height=1cm]{test}\vspace{0.1cm}\linebreak\sffamily\tiny
subtext\linebreak
more text} &%
\multirow{3}{0.30\framewidth}{\centering\large\textsc{Project name}\linebreak\textbf{Current document, more text, and even more text, still more text}} &%
a \\
& & b \\
& & c \\
\end{tabularx}
}
\end{document}

I've marked with yellow color the text that was overflown out of the cell. Also, if I put everything in a box, and measure that box, it is shorter than actual text contained in the box. Why is that?

Overflown table cell

share|improve this question
1  
@ipavlic: I changed your code a tiny bit to allow it to compile without the missing image. If you want to use a dummy image in your examples, load the graphicx package with the [demo] option, and just use anything you'd like as a placeholder name of the image when including it. See the revision history to check what I have changed. –  Martin Tapankov Feb 25 '11 at 12:41
    
@Martin Tapankov: Thanks. I left that in the code in case it was relevant. –  ipavlic Feb 25 '11 at 12:46
    
@ipavlic: Just remove such code and recompile to see if the issue is gone. It it isn't, the code isn't relevant. It should be a minimal example after all. –  Martin Scharrer Feb 25 '11 at 12:47
    
Note that using only X columns with tabularx doesn't make much sense. You can just replace them (or at least the first two) with p{.333\framewidth} instead. –  Martin Scharrer Feb 25 '11 at 12:48
    
@Martin Scharrer: It seems to me that using p{.333\framewidth} yields a table that is around 2 cm wider :/. –  ipavlic Feb 25 '11 at 13:01
show 1 more comment

1 Answer

up vote 6 down vote accepted

You are using \multirow{3}{...} for this cell and therefore explicitly requesting three lines, but then you have enough text for four lines. Either change it to \multirow{4}{...} and add a \\ or change the column type to p{.3\framewidth}.

Note that AFAIK \multirow sets the official height of the content to be only the first line and the rest is then part of the depth.

See also the answers to the questions "Why doesn't \settoheight of \parbox work?" and "Measuring height of fixed-width text box" which explain how to measure the correct height for such boxes.


In response to the OP's comment:

You could define all three columns as p type columns and enter the right side content as one cell, like the others. You can use \newline as line break command:

\documentclass[a4paper,draft]{article}

\usepackage{calc}
\usepackage{graphicx}
\usepackage{tabularx,multirow}

\usepackage{geometry}
\geometry{hmargin=0cm}

\newlength\framewidth
\setlength{\framewidth}{\paperwidth}
\addtolength{\framewidth}{-3cm}

\begin{document}
\centering

\fbox{%
\begin{tabularx}{\framewidth}{p{.3\framewidth}p{.3\framewidth}p{.3\framewidth}}
 \multirow{3}{0.30\framewidth}{%
   \centering
   %\includegraphics[width=0.2\textwidth]{Images/Logo}%
   \rule{.2\textwidth}{1cm}
   \vspace{0.1cm}\linebreak\sffamily\tiny
   subtext\linebreak
   more text} &%
   \centering\large\textsc{Project name}\linebreak\textbf{Current document, more text, and even more text, still more text}
  &%
  { a \newline b \newline c \newline } \\
\end{tabularx}%
}
\end{document}

I think the tabular environment might be not the best option in this case. Three minipages side by side would be better suited:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{calc}


\newlength\framewidth
\setlength{\framewidth}{\textwidth-4\tabcolsep-2\fboxsep}

\begin{document}
\centering

% Horizontal rule for comparison
\hrule\par\bigskip

\fbox{%
\begin{minipage}[t]{.333\framewidth}
   \centering
   \vspace*{0pt}
   %\includegraphics[width=0.2\textwidth]{Images/Logo}%
   \rule{.8\textwidth}{1cm}% graphic dummy
   \\[.1cm]\sffamily\tiny
   subtext\linebreak
   more text
\end{minipage}%
\hspace{2\tabcolsep}%
\begin{minipage}[t]{.333\framewidth}
   \centering\large\textsc{Project name}\\
   \bfseries Current document, more text, and even more text,
   still more text
\end{minipage}%
\hspace{2\tabcolsep}%
\begin{minipage}[t]{.333\framewidth}
   a \\ b \\ c
\end{minipage}%
}
\end{document}
share|improve this answer
    
What if I don't know the contained text in advance? I can't just insert new rows into my source every time that text changes. As for the p{.3\framewidth}, that would imply that the a row is as high as Project name... row. I would prefer that rows a, b and c stretch evenly if necessary to accomodate multirow'd Project name.... –  ipavlic Feb 25 '11 at 12:52
    
@ipavlic: See my updated answer. I think the minipage solution is best suited for your application. If this is not so, tell me. –  Martin Scharrer Feb 25 '11 at 13:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.