0

I asked a very similar question yesterday that I thought I would be able to abstract into this problem but I can't.

Here's an image of the table :

enter image description here

Here's the code :

\documentclass{article}
\usepackage{tabularx,booktabs}

\begin{document}
\def\arraystretch{1.2}
\noindent
\begin{tabularx}{\textwidth}{XX}

\large RTT

\normalsize
&

\small
\begin{tabular}[t]{ll}
RTT (Rare Quality Control)\\
Telephone: 02342 4945433 \\
Fax: 09234 2345234 \\
Open Monday to Friday \\
8.30am to 5:30pm.\\
\end{tabular}\\[8em]
\normalsize

\large RTT Customer Service  Centre
\normalsize
&
\small
\begin{tabular}[t]{ll}
RTT National Customer Service Centre \\
Thurnui \\
Gallerrri \\
Thorsantt upon River \\
GWW 5EW \\
\end{tabular}\\[8em]
\normalsize


\vspace{0.5cm}

\large Constituency Office
\normalsize
&
\small
\begin{tabular}[t]{ll}
Government Office \\
Townington \\
Bigtree Associations \\
33 Flaxington Street \\
Broshintree\\
GH78 879 \\
01235 777342 \\
\end{tabular}\\[8em]
\normalsize

% this line should be split or it looks too long
\large Local Government \\
\large Moneylender
\normalsize

&
\small
\begin{tabular}[t]{ll}
Local Government Moneylender \\
Rahley House \\
87 Haxtree Road \\
Devon  \\
DVY 78J \\
01823 734098\\
\end{tabular}\\[8em]
\normalsize


\end{tabularx}
\end{document}

I want to be able to break the lines and have the left text inline with the text on the right, something along the lines of :

    Wacld Bort               Waxel LTD
    Hurbunthon               Somewhere street
                             National Park
                             GHS 7UY
                             London


    National Eraser          National Eraser Pencil Appreciation
    Pencil Appreciation      Pendff
                             Hurbunthon
                             Maxthwaite upon Thyme
                             GRH 73G

The place names on the left have line breaks and the top of them are in line with the top of the addresses on the right.

But I'm not sure how to do this, I don't know why it goes really out of line on the third element either.

Thanks

3
  • The vertical position of the left entry goes out of sync with the right base line by a stray \vspace, for example.
  • The right cell tables do not use more than one column. Also the left and right \tabskips should be suppressed in the inner tables: \begin{tabular}{@{}l@{}}.
  • The font sizes can be added to the columns more efficiently using package array.
  • The inner tables are not necessary.
  • \newline ends a line in a cell, \tabularnewline ends a table row. The example below defines \\ as \newline, then the shorter \\ can be used instead of \newline, but the table rows must be ended with \tabularnewline.

Full example:

\documentclass{article}
\usepackage{array,tabularx,booktabs}

\begin{document}
  \def\arraystretch{1.2}
  \setlength{\defaultaddspace}{1em}
  \noindent
  \begin{tabularx}{\textwidth}{
    @{}
    >{\large\let\\\newline}X
    >{\small\let\\\newline}X
    @{}
  }
    RTT
    &  
    RTT (Rare Quality Control)\\
    Telephone: 02342 4945433 \\
    Fax: 09234 2345234 \\
    Open Monday to Friday \\
    8.30am to 5:30pm.
    \tabularnewline
    \addlinespace
    RTT Customer Service Centre
    &
    RTT National Customer Service Centre \\
    Thurnui \\
    Gallerrri \\
    Thorsantt upon River \\
    GWW 5EW
    \tabularnewline
    \addlinespace
    Constituency Office
    &
    Government Office \\
    Townington \\
    Bigtree Associations \\
    33 Flaxington Street \\
    Broshintree\\
    GH78 879 \\
    01235 777342
    \tabularnewline
    \addlinespace
    Local Government \\
    Moneylender
    &
    Local Government Moneylender \\
    Rahley House \\
    87 Haxtree Road \\
    Devon  \\
    DVY 78J \\
    01823 734098
  \end{tabularx}
\end{document}  

Result

  • thanks very much Heiko, I'm going to have to go back over these when I've finished this as there's a lot to learn for me table wise. Cheers though :) – baxx Jun 9 '15 at 12:37
  • I'm also interested as to how I would add a line break into the left hand side info, if there was a long name like This place on the hill in the Alps get a train here, I might want to force a line break (as LaTeX will hyphenate which may look a bit off in a list). Big improvement on what I had though thanks – baxx Jun 9 '15 at 12:41
  • 1
    This is feature of tabularx. If you like to broke a line without hyphenation of words in cell, than you define new column type, for example \newcolumntype{L}{>{\raggedright\arraybackslash}X} . – Zarko Jun 9 '15 at 12:52
  • @baxx The manual line break in the left column cell is shown in the example. X cells means, a p cell is the basis (similar to \parbox[t]), where \newline can be used. – Heiko Oberdiek Jun 9 '15 at 13:06
  • @Zarko Addition: \arraybackslash defines \\ as \tabularnewline. Manual line breaks in the cell must then be done with \newline. – Heiko Oberdiek Jun 9 '15 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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