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.

I would like to align the content of each cell (of the first column) to the top. The approaches presented here did not apply. Maybe it has something to do with die tabular-environment inside the tabluarx-environment?

How it looks like

i1

How I would like it to look like

i2

MWE

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

\begin{document}

    \begin{tabularx}{\textwidth}{lX}
        \toprule
        Mittel    & technische Details\\
        \midrule
        %first row of tabularx
        Laptop      &
            \begin{tabular}{ll}
            MacBook Pro & \\
            Baujahr 2010 & \\ 
            Prozessor & 2.4 GHz Intel Core 2 Duo \\
            Speicher & 4 GB 1067 MHz DDR3 \\
            Software & Mac OS X Lion 10.7.5 (11G63)
            \end{tabular}\\[3em]
        %second row of tabularx
        Programmierumgebung          &
            \begin{tabular}{ll}
            Version & 8.0.4.0 \\
            Plattform & Mac OS x86 (32-bit, 64-bit Kernel)
            \end{tabular}\\
        \bottomrule
    \end{tabularx}

\end{document}
share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

enter image description here

You can make the inner tabulars top align by using [t] It may just be an artifact of your small example but tabularx can do nothing to help here as the inner tabular is fixed to its natural width so can not reflow to whatever width the X column specifies.

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

\begin{document}
\noindent
    \begin{tabularx}{\textwidth}{lX}
        \toprule
        Mittel    & technische Details\\
        \midrule
        %first row of tabularx
        Laptop      &
            \begin{tabular}[t]{ll}
            MacBook Pro & \\
            Baujahr 2010 & \\ 
            Prozessor & 2.4 GHz Intel Core 2 Duo \\
            Speicher & 4 GB 1067 MHz DDR3 \\
            Software & Mac OS X Lion 10.7.5 (11G63)
            \end{tabular}\\[3em]
        %second row of tabularx
        Programmierumgebung          &
            \begin{tabular}[t]{ll}
            Version & 8.0.4.0 \\
            Plattform & Mac OS x86 (32-bit, 64-bit Kernel)
            \end{tabular}\\
        \bottomrule
    \end{tabularx}

\end{document}
share|improve this answer
    
I've noticed there's a significant difference between the X column type and the "older" l and p{<width>} column types: If there's a tabular environment in a row and X column, it's necessary to suppress the whitespace at the left edge of the environment explicitly, by inserting @{}, in order to get its contents to line up with other cells in the same column that are not tabulars. (See also the output of your MWE.) Inserting @{} isn't needed if the tabular environment occurs in a column of type p or l. Is this a "feature" of the tabularx environment? –  Mico Mar 21 '13 at 13:41
    
@Mico Not really any different: X is p by the time that the table is typeset it just calculates a width and then literally generates a p{...} column specification and calls a normal tabular. –  David Carlisle Mar 21 '13 at 13:45
add comment

Why not use a single tabularx environment instead of one inside a tabular?

\begin{tabularx}{\textwidth}{llX}
    \toprule
    Mittel              & technische Details & \\
    \midrule
    Laptop              & MacBook Pro  & \\
                        & Baujahr 2010 & \\ 
                        & Prozessor    & 2.4 GHz Intel Core 2 Duo \\
                        & Speicher     & 4 GB 1067 MHz DDR3 \\
                        & Software     & Mac OS X Lion 10.7.5 (11G63) \\[3em]
    Programmierumgebung & Version      & 8.0.4.0 \\
                        & Plattform    & Mac OS x86 (32-bit, 64-bit Kernel)\\
    \bottomrule
\end{tabularx}

sample output

share|improve this answer
    
Maybe the easiest way. –  John Mar 21 '13 at 12:39
add comment

One can specify the vertical alignment -- top, middle (default), and bottom -- of a tabular environment via an optional argument. In the code below, I use [t] (for "top" alignment). Note that it's also necessary now to suppress explicitly, via a @{} directive, the whitespace that's otherwise inserted at the left edge of the cell when using the X column type for a cell that contains a tabular environment.

enter image description here

\documentclass{article}
\usepackage{tabularx,booktabs} 
\begin{document}
\noindent
  \begin{tabularx}{\textwidth}{lX}
    \toprule
    Mittel  & technische Details\\
    \midrule
    %first row of tabularx
    Laptop    &
      \begin{tabular}[t]{@{}ll} 
         % use [t] alignment specifier, and @{} to 
         % suppress extra whitespace at left edge
      MacBook Pro & \\
      Baujahr 2010 & \\ 
      Prozessor & 2.4 GHz Intel Core 2 Duo \\
      Speicher & 4 GB 1067 MHz DDR3 \\
      Software & Mac OS X Lion 10.7.5 (11G63)
      \end{tabular}\\[5em]
    %second row of tabularx
    Programmierumgebung      &
      \begin{tabular}[t]{@{}ll} 
      Version & 8.0.4.0 \\
      Plattform & Mac OS x86 (32-bit, 64-bit Kernel)
      \end{tabular}\\
    \bottomrule
  \end{tabularx}
\end{document}
share|improve this answer
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.