1

I'm trying to format a table like the following:

0.0a summarry       b other summarry
                      (long)
 .1a junk           b more junk
1.0a etc            b so forth

Ie, with all the contents top- and left-aligned and everything lined up semi-nicely and the main columns the same size.

So far the best I've been able to come up with is:

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{array}
\setmainfont{DejaVu Sans}
\title{---}
\date{}
\newcolumntype{T}{>{\vtop\bgroup\vspace*{-\ht\strutbox}\hbox\bgroup}
                   c<{\egroup\egroup}}
\begin{document}
  \begin{tabular}{ T T T l T l }
    \hline
    0&.0&a&
    summary
    &b&
    other summary (long)
    \\ \hline
    &.1&a&
    junk
    &b&
    more junk
    \\ \hline
    1&.0&a&
    etc
    &b&
    so forth
    \\ \hline
  \end{tabular}
\end{document}
3
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{array,ragged2e}
\setmainfont{DejaVu Sans}
\begin{document}
\begin{tabular}{ r @{} l >{\RaggedRight}p{3cm} r >{\RaggedRight}p{3cm} } \hline
    0.0 &a&  summary &b& other summary (long)        \\ \hline
     .1 &a& junk     &b&  more junk \\ \hline
    1.0 &a& etc      &b&  so forth  \\ \hline
  \end{tabular}
\end{document}

enter image description here

2
\documentclass{article}
\usepackage{booktabs} % <--- for drawing rules
%--------------------------------------
\begin{document}
  \begin{tabular}{p{.05\textwidth}p{.4\textwidth}p{.03\textwidth}p{.4\textwidth}}
    \toprule
    0.0a & summary   &b & other summary (long) \\ \midrule
    0.1a & junk      &b & more junk            \\ \midrule
    1.0a & etc       &b & so forth             \\ \bottomrule
  \end{tabular}
  %--------------------------------------
\end{document}

enter image description here

2

It isn't clear what output you are trying to make with the \vtop construction (which isn't really LaTeX at all). It makes each entry a single line with odd vertical alignment. Your suggested output appeared to show 4 columns but the code has 6? If it alternates between a numeric column and a longer description, perhaps tabularx and lXlX is what you are looking for

\documentclass{article}
\usepackage{amsmath}
%\usepackage{fontspec}
\usepackage{array,tabularx,dcolumn}
%\setmainfont{DejaVu Sans}
\title{---}
\date{}


\begin{document}
 \centering
 \begin{tabularx}\linewidth{D{.}{.}{-1}llXlX}
    \hline
    0.0&a&  summary    &b&  other summary (long)
    \\ \hline
    .1&a& junk &b&  more junk
    \\ \hline
    1.0&a& etc    &b&    so forth
    \\ \hline
  \end{tabularx}
\end{document}
  • The code has 6 columns to get the components of each number to line up (eg, the .1 directly below the .0). – David X Mar 26 '12 at 12:02
  • oh in that case you could use dcolumn I have updated my answer – David Carlisle Mar 26 '12 at 12:58

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.