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.

Welcome to part 4 in a series of questions about me trying to improve my crazy layout!

I'm using tabu to create a table with a central heading, and two small blocks of text on the left and right which are vertically centered.

Now I'd like to add a small subheading — but the main heading should still be vertically centered with respect to the left and right text blocks. Here's the starting point:

\documentclass{article}
\usepackage{tabu} 

\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
    \Huge Here's a Title
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\ \tabucline \\
\end{tabu}

\end{document}

When I use

\Huge Here's a Title \linebreak \normalsize And a subtitle!

I get this:

Clearly the centering is preserved overall, but I don't want the subtitle to contribute to the positioning. So I tried \smash:

\Huge Here's a Title \smash{\linebreak \normalsize And a subtitle!}

But the result is no better (in fact, it's worse):

(And I tried some other arrangements too, to no avail.) Is there any way to do this, or am I crazy for trying?

share|improve this question
    
I am not sure where the sub title is supposed to go? On top of the last \tabucline? Do you want it below that perhaps? –  Peter Grill Oct 9 '12 at 7:33
    
@PeterGrill It should be below the main title, except I don't want it to take up any space (so maybe it will overlap with the \tabucline, I don't care about that). –  jtbandes Oct 9 '12 at 8:08

4 Answers 4

up vote 5 down vote accepted

Based on the comments you seem to want to make sure that the subtitle does not take up any space. Well, my usual overkill option of using tikz provides a method to place text without influencing the positioning.

You mark the two end points of where you want the text centered via a \tikzmark and give each of these marks a name. Then after the table you can place text anywhere relative to these marked points. Below I have set the default (show in red) placement below the title, but you can also use the first optional parameter to the \AddSubTitle macro to tweak the positioning and color as I have done in the second example (text in blue):

enter image description here

I am not sure that you would want to place text on top of the \tabucline, but that might make sense for an ornament. Anyway you have the flexibility to place it where you want.

Perhaps something like this first example below might be useful where I have added a white fill around the text so that the subtitle is not obscured:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{tabu} 
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand*{\AddSubTitle}[4][]{%
    % #1 = draw options
    % #2 = left point
    % #3 = right point
    % #4 = text
    \begin{tikzpicture}[overlay,remember picture]
        \coordinate (MidPoint) at ($(#2.south)!0.5!(#3.south)$);
        \node [red, #1] at (MidPoint)  {#4};
    \end{tikzpicture}%
}%

\newcommand{\MyTabu}{%  Make it easier to repeat for testing purposes
\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
    \Huge \tikzmark{left}Here's a Title\tikzmark{right}
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\ \tabucline \\
\end{tabu}
}%
\begin{document}

\MyTabu
\AddSubTitle{left}{right}{And a subtitle!}

\vspace*{1.0cm}
\MyTabu
\AddSubTitle[blue, yshift=0.2cm]{left}{right}{And a subtitle!}

\vspace*{1.0cm}
\MyTabu
\AddSubTitle[red, yshift=0.5cm, rotate=45]{left}{right}{And a subtitle!}

\end{document}
share|improve this answer

Put the subtitle in a centred multicolumn spanning the three columns (I put a \strut after the huge title to have better spacing):

\documentclass{article}
\usepackage{tabu} 

\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
    \Huge Here's a Title\strut
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\\tabucline\\
\multicolumn{3}{|c|}{Her is the subtitle}\\ \tabucline \\
\end{tabu}

\end{document}

enter image description here

Or just in a separate row (experiment with \strut after the subtitle to see if you find the spacing better):

\documentclass{article}
\usepackage{tabu} 

\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
    \Huge Here's a Title\strut
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\
& Her is the subtitle \strut &\\ \tabucline \\
\end{tabu}

\end{document}

enter image description here

Your third option is to use the package textpos. By placing :

\documentclass{article}
\usepackage{textpos} 
\usepackage{tabu}

\setlength{\TPHorizModule}{\textwidth}
\setlength{\TPVertModule}{\textheight}


\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
    \Huge Here's a Title\strut
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
 \\ \tabucline \\
\end{tabu}

\begin{textblock}{0.8}[0.5,0.5](0.5,-0.01)
\noindent\centering Subtitle
\end{textblock}

\end{document}

enter image description here

share|improve this answer
    
Do you need all the extra space in the last image? –  azetina Oct 9 '12 at 14:10
    
No, but standalone is not compatible with textpos, and I had no time for cropping. –  Sveinung Oct 9 '12 at 14:26

You can locally disable the interline skip mechanism:

\documentclass{article}
\usepackage{tabu}

\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline
    \scriptsize This is something \linebreak on the left
    &
    \offinterlineskip
    \Huge\strut Here's a Title\par
    \vspace{-2pt}
    \normalsize\strut And a subtitle
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\\tabucline\\
\end{tabu}

\end{document}

The \vspace{-2pt} seems necessary, particularly because the huge title has no descenders. By inserting struts you ensure that the characters don't touch the lines.

enter image description here

Alternatively, put the subtitle in another row:

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline
    \scriptsize This is something \linebreak on the left
    &
    \Huge\strut Here's a Title
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\
    & And a subtitle & \\
\tabucline\\
\end{tabu}

enter image description here

share|improve this answer
    
Even with \offinterlineskip the title is in different positions with/without the subtitle; I want it to stay in the same place. Putting it in a new row would work except then its proximity to the main title is constrained by the left and right cell heights. –  jtbandes Oct 9 '12 at 8:33

Can you be happy with phantom space?

\documentclass{article}
\usepackage{tabu}

\begin{document}

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left
    &
     \phantom{And a subtitle!} \Huge Here's a Title \linebreak \normalsize And a subtitle!
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \\ \tabucline \\
\end{tabu}

\noindent OR

\noindent
\begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|} \tabucline \\
    \scriptsize This is something \linebreak on the left \linebreak  \phantom{And a subtitle!}
    &
     \Huge Here's a Title \linebreak \normalsize And a subtitle!
    &
    \scriptsize And here's some stuff \linebreak on the \linebreak right side
    \linebreak \phantom{And a subtitle!}
    \\ \tabucline \\
\end{tabu}

\end{document}

enter image description here

share|improve this answer

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.