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 am new to LaTeX. I am trying to stack tables one on top of another but I seem to be having a problem doing that while including the geometry package. I am doing this in order to simulate very complex table structures that would otherwise be prohibitive using standard table definitions. Here are some of my requirements:

  • The tables widths must be specified in cm.
  • The tables must be arranged vertically and left aligned with each other.
  • The tables must not have any gaps between them.
  • The default page margins must go away.
  • The tables must be tabularx objects in order to take advantage of its features.

Here is the code I am using for testing:

\documentclass[letterpaper]{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{tabularx}
\begin{document}
    \noindent
    \begin{tabularx}{13.25cm}{|l|}
        \hline {Test One}  \\ \hline
    \end{tabularx}
    \begin{tabularx}{13.25cm}{|l|}
        \hline {Test Two}  \\ \hline
    \end{tabularx}
    \begin{tabularx}{13.25cm}{|l|}
        \hline {Test Three}  \\ \hline
    \end{tabularx}
\end{document}

This code will arrange the tables in some kind of two column array. When the geometry line is removed the tables will be arranged correctly, but I need this line in order to instruct LaTeX to give me control of the page margins.

In both cases there seems to be a 1 point gap between the tables which should not be there.

Any help is appreciated.

share|improve this question
    
You do not want tabularx here (there are no multi-line X columns so tabularx is not doing anything.) You have specified that the page is 8.5in wide but the tables are 13.25cm which is more than half of that yet you say you want a two column layout? –  David Carlisle Sep 25 '12 at 16:34
    
As this is example code, tabularx is not intended to do anything. Consider that I posted a list of requirements, therefore the answers must resolve those constraints in order for my post to be considered "answered". In my production code I use many features from tabularx, but you don't need to see this in order to answer my question. Lastly I never said I wanted a two column layout. I was merely explaining the unexpected results of my provided code which is one of the main reasons I even bothered posting this question in the first place. –  NiGHTS Sep 25 '12 at 17:09

1 Answer 1

It is hard to know what the intention of the posted code is, but it is setting a paragraph composed entirely of tables, thus almost no flexibility, just a single word space per line.

Adding \raggedrightafter \begin{document} gives TeX a chance to line things up, but with the specified page size there is only room for one table per line so they all stack vertically. If the page size were wider or the tables narrower you would get more per line.


In the following I use X columns in the tabularx I removed the { } group around the table cell as they do not do anything. I set the table width to half the text width so that you get a two column layout and I removed the word space between each table, replacing it by a penalty to allow line breaking.


enter image description here

\documentclass[letterpaper]{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{tabularx}
\begin{document}
\raggedright
\offinterlineskip
    \noindent
    \begin{tabularx}{.5\textwidth}{|X|}
        \hline Test One  \\ \hline
    \end{tabularx}\linebreak[0]%
    \begin{tabularx}{.5\textwidth}{|X|}
        \hline Test Two  \\ \hline
    \end{tabularx}\linebreak[0]%
    \begin{tabularx}{.5\textwidth}{|X|}
        \hline Test Three  \\ \hline
    \end{tabularx}%
\end{document}
share|improve this answer
    
This resolves most of my issues, thank you. The only requirement not addressed is the one point gap between "Test One" and "Test Three" in your image. Thankfully this is not a major issue for me right now but it would be nice to know how to eliminate that gap. Again, thank you for your help! –  NiGHTS Sep 25 '12 at 17:19
    
\offinterlineskip added and image updated –  David Carlisle Sep 25 '12 at 18:03

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.