0

I have an issue with the following tabularx code. I am trying to rotate some longer text by 90 degrees so that I can keep the column width small. I have reduced the number of columns for this example but in my actual tex file I have 6 columns, which gets rather tight.

The problem I have with this is that the first column header is not exactly flushed left, but one line right of that:

\begin{table}
\begin{tabularx}{\textwidth}{|X|X|}
    \hline
    \multicolumn{1}{|l|}{
        \rotatebox{90}{
            \parbox {2cm}{\flushleft \bfseries Foo \\ (Foo Bar and Baz)} }} & 
    \multicolumn{1}{l|}{
            \rotatebox{90}{\bfseries Something} } \\\hline

    Yes       & No\footnote{\url{https://example.com}} \\\hline

\end{tabularx}
\end{table}

Image 1

When I omit the \flushleft in the \parbox then the text is justified:

\begin{table}
\begin{tabularx}{\textwidth}{|X|X|}
    \hline
    \multicolumn{1}{|l|}{%
        \rotatebox{90}{ \parbox {2cm}{
            \bfseries Foo \\ (Foo Bar and Baz)} }} & 
    \multicolumn{1}{l|}{ 
        \rotatebox{90}{ \bfseries Something} } \\\hline

    Yes       & No\footnote{\url{https://example.com}} \\\hline

\end{tabularx}
\end{table}

Image 2

How can I get the text aligned to the bottom and to the left? Or otherwise is there some other best practice to deal with long header text?

lanoxx
  • 1,093

1 Answers1

1
\rotatebox{90}{ \parbox {2cm}{

inserts two space characters you do not want:

\rotatebox{90}{\parbox {2cm}{\raggedright

note flushleft is intended as an environment, and adds vertical space \raggedright is the declaration form

(See comparisons of \begin{center} and \centering on this site).

David Carlisle
  • 757,742