1

I am currently trying to create one pagers (profiles describing a unit) and my plan was to use a table to do that. It works quite well except for the alignment of the text inside the table. I am using p{...} since I'd like a top-left alignment but this leads to the following output:

enter image description here

Alignment to the bottom (b{...}) works fine and the issues only seems to occur with a rotation present in the left column. I already tried various things like different means of rotation (e.g. \begin{sideways}), experimenting with the column width and so on.

\documentclass[twoside, english, draft]{article}    

\usepackage{rotating}       
\usepackage{array}              
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}

\begin{document}

\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax


\begin{center}
\begin{longtable}{
    p{.05\NetTableWidth}
    p{.45\NetTableWidth}
    p{.45\NetTableWidth}
}
\toprule
& \textbf{Parameter a} & \textbf{Parameter b} \\
\midrule
\rotatebox{90}{\textbf{Factor a}} 
& 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
& 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. 
\\ 
\addlinespace[1em]
\rotatebox{90}{\textbf{Factor b}} 
& 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
& 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\\ 
\bottomrule 
\end{longtable}
\end{center}

\end{document}
  • 1
    Welcome to TeX.SE! Try \rotatebox[origin=center]{90}{\textbf{Factor a}} and likewise \rotatebox[origin=center]{90}{\textbf{Factor b}}. – user121799 Sep 12 '18 at 15:20
  • 1
    unrelated but don't put longtable in a center environment (it doesn't centre it) – David Carlisle Sep 12 '18 at 15:22
  • 1
    perhaps just because you made a smaller example but the calculation of \NetTableWidth assumes a table of 4 columns and 5 rules, but the one here has 3 columns and no rules. – David Carlisle Sep 12 '18 at 15:24
  • Thank's a lot! I found the calculation and the associated table on stackexchange and forgot to change the calculation after working on the table since the calculation was not explained further... – OffsetWrench Sep 12 '18 at 16:07
0

Use the key [origin=r]. You can fine-tune the alignment with a \raisebox – I give an example with the second row:

\documentclass[twoside, english, draft]{article}

\usepackage{rotating}
\usepackage{array}
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}

\begin{document}

\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax

\begin{longtable}{
    p{.05\NetTableWidth}
    p{.45\NetTableWidth}
    p{.45\NetTableWidth}
}
\toprule
& \textbf{Parameter a} & \textbf{Parameter b} \\
\midrule
\rotatebox[origin=r]{90}{\textbf{Factor a}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
\\
\addlinespace[1em]
\raisebox{0.43ex}{\rotatebox[origin=r]{90}{\textbf{Factor b}}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\\
\bottomrule
\end{longtable}

\end{document} 

enter image description here

  • I tried both [origin=center] and [origin=r]. Both provide good results with the latter one being the aesthetically more pleasing solution :) – OffsetWrench Sep 12 '18 at 16:02
0

Bernard gave a great answer, but here is another way to do it

You can use \multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{<cell contents>}}. Here, the = means that the multirow width will be determined by the table preamble.

enter image description here

\documentclass[twoside, english, draft]{article}    

\usepackage{rotating}       
\usepackage{array}              
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{adjustbox}
\usepackage{multirow}


\begin{document}

\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax


\begin{center}
\begin{longtable}{
    p{.05\NetTableWidth}
    p{.45\NetTableWidth}
    p{.45\NetTableWidth}
}
    \toprule
    & \textbf{Parameter a} & \textbf{Parameter b}
    \\
    \midrule

    \multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{\textbf{Factor a}}}
    & 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
    lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
    & 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
    lum ut, placerat ac, adipiscing vitae, felis. 
    \\ 

    \addlinespace[1em]
    \multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{\textbf{Factor b}}}
    & 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
    lum ut, placerat ac, adipiscing vitae, felis.
    & 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
    lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
    Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
    \\ 
    \bottomrule 
\end{longtable}
\end{center}

\end{document}
  • Thanks for the input! I thought about using multirow since all of the examples of vertical cell content I could come by were spreading over multiple rows. I was however afraid of the added complexity and many possibilities to screw up the adaption to my use case :) (LateX Beginner with quite limited knowledge) – OffsetWrench Sep 12 '18 at 16:22

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.