3

This is my table:

https://dl.dropboxusercontent.com/u/52838329/tabular.png

I have a few problems:

  1. I want both columns to take each 50% of the page width (excl margin), but the second column's text needs to be aligned right.
  2. The last vertical line is not correctly placed
  3. The first and last row need to be a bit higher so the text fits better.

    \begin{tabularx}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}
    \hline
    \textbf{{\Large Activa}} & \textbf{{\Large Passiva}}\\ \hline
    \hline 
    \textbf{Aanwendingsvormen} van het vermogen & \textbf{Vermogensbronnen}\\
    
    \begin{itemize}
    \item Bezittingen
    \item Vorderingen
    \end{itemize}
    &
    \begin{itemize}
    \item Eigen vermogen
    \item Vreemd vermogen
    \end{itemize}\\
    
    \textbf{Ondernemingsmiddelen} & \textbf{Ondernemingsbronnen}\\
    Welke middelen heeft de onderneming om haar activiteit te ontwikkelen? & Hoe financiert de onderneming de ondernemingsmiddelen.\\
    \hline \hline
    \textbf{{\Large Vermogen} van de onderneming} & \textbf{{\Large Vermogen} van de onderneming}\\\hline
    \end{tabularx}
    

I didn't find anything on this, so any help is appreciated!

1 Answer 1

2

Here are some things you need to do:

  • Use \textbf{\Large\strut ...} in one of the header entries. This inserts a vertical strut of the appropriate size to obtain better spacing. There's also more ideas in terms of vertical adjustment of table entries in Column and row padding in tables.

  • Include the array package in your preamble

    \usepackage{array}% http://ctan.org/pkg/array
    

    and use a tabularx column specification of the form

    \begin{tabularx}{\textwidth}{|>{\raggedright}X|>{\raggedleft\arraybackslash}X|}
    % ...
    \end{tabularx}
    

    This inserts \raggedright [\raggedleft] in the first [second] column so items should be left- [right-]aligned. Note that lists do not conform to this adjustment. To that end, I've used varwidth's varwidth environment for capturing the list in a box of natural width (if it is smaller than the width of the column, or \linewidth).

  • Also, use \noindent before tabularx:

    \noindent
    \begin{tabularx}{\textwidth}{...}
    %...
    \end{tabularx}
    

    otherwise your tabularx position won't sit flush with the margins.

Here is a complete MWE:

enter image description here

\documentclass{article}
\usepackage{array,tabularx,varwidth}% http://ctan.org/pkg/{array,tabularx,varwidth}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|>{\raggedright}X|>{\raggedleft\arraybackslash}X|}
  \hline
  \textbf{{\Large\strut Activa}} & \textbf{{\Large Passiva}} \\
  \hline\hline 
  \textbf{Aanwendingsvormen} van het vermogen & \textbf{Vermogensbronnen} \\[1.5\normalbaselineskip]
  \begin{varwidth}[t]{\linewidth}
    \begin{itemize}
      \item Bezittingen
      \item Vorderingen
    \end{itemize}
  \end{varwidth} &
  \begin{varwidth}[t]{\linewidth}
    \begin{itemize}
      \item Eigen vermogen
      \item Vreemd vermogen
    \end{itemize}
  \end{varwidth} \\[2\normalbaselineskip]
  \textbf{Ondernemingsmiddelen} & \textbf{Ondernemingsbronnen} \\
  Welke middelen heeft de onderneming om haar activiteit te ontwikkelen? & 
  Hoe financiert de onderneming de ondernemingsmiddelen.\\
  \hline\hline
  \textbf{{\Large\strut Vermogen} van de onderneming} & 
  \textbf{{\Large Vermogen} van de onderneming} \\
  \hline
\end{tabularx}
\end{document}

Unknown (or incorrect) hyphenation patterns could also be problematic when it comes to line-breaking (not the case/issue here). If need be, you can manually force a different hyphenation using a blah\-blah\-blah approach.

4
  • 1
    Thanks! Worked perfectly. Only the list is indeed still left. I tried flushright, but that didn't help either. What else can I do?
    – Aaron
    Aug 22, 2013 at 19:14
  • @Aaron: I've adapted the solution a bit, mainly with the addition of varwidth to align the itemize. It's one option. Check the revision history for a complete picture of the changes. Since you're using a tabularx environment for "parallel typesetting", the vertical adjustments around the itemize is natural. The problems around these vertical adjustments stem from the boxing; for more on this discussion, see How to keep a constant \baselineskip when using minipages (or \parboxes)?.
    – Werner
    Aug 22, 2013 at 20:33
  • 1
    I just did a complete install of texlive (upgrade), but varwidth is still not installed? How can install this? (Ubuntu)
    – Aaron
    Aug 23, 2013 at 11:27
  • @Aaron: sudo tlmgr install varwidth? Perhaps see How do I update my TeX distribution? or How do I install an individual package on a Linux system?
    – Werner
    Aug 23, 2013 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .