0

I've been having trouble getting a text-width sideways table to look right. In the example below the end column separator is strangely detached from the end of the table as can be seen below.

Image displaying how this code renders in Texpad-2

How can I get rid of this gap? The code is as follows:

\documentclass{article}

\usepackage{rotating}
\usepackage{tabularx}
\usepackage{lipsum}

\begin{document}

\begin{sidewaystable}
    \caption{This is my table}
    \centering
    \begin{tabularx}{\textwidth}{|p{0.15\textwidth}|p{0.4\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|}
        \hline
        \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} & \textbf{Column 4}\\ 
        \hline
        Row 1 & \lipsum[2] & some text & more text in here \\
        \hline
        Row 2 & \lipsum[3] & some text & more text in here \\
        \hline
    \end{tabularx}
\end{sidewaystable} 

\end{document}
1

A tabularx environment is useless if it has not at least one X column. Here your table is wider than \textheight (due to 8 \tabcolsep`s). Here is a correct version of the code:

\documentclass{article}

\usepackage{rotating}
\usepackage{tabularx}
\usepackage{lipsum}

\begin{document}

\begin{sidewaystable}
    \caption{This is my table}
\setlength{\extrarowheight}{2pt}
    \centering
    \begin{tabularx}{\textwidth}{|>{\hsize=0.64\hsize}X|>{\hsize=1.68\hsize}X|*{2}{>{\hsize=0.84\hsize}X|}}
        \hline
        \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} & \textbf{Column 4}\\
        \hline
        Row 1 & \lipsum[2] & some text & more text in here \\
        \hline
        Row 2 & \lipsum[3] & some text & more text in here \\
        \hline
    \end{tabularx}
\end{sidewaystable}

\end{document} 

enter image description here

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.