3

I am trying to vertically center text in a table but when I try to use \vspace, the entire row is shifted instead of just one cell. I have copied the LaTeX below that will demonstrate the effects if you use and don't use \vspace. I used the rotating command also which may be the reason this is so difficult.

Here is what using no vspace looks like, I want Lorem1 and Ipsum1 to be centered vertically. Normal Picture

I tried to use \vspace to perform this task, but it doesn't accomplish what I want. I used a negative value in the example below.

Picture using vspace

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{lipsum}
\begin{document}




\newcolumntype{E}{>{\centering\arraybackslash}m{7cm}}
\newcommand\RotText[1]{\fontsize{9}{9}\selectfont \rotatebox{90}{\parbox{2.6cm}{\centering#1}}}

\centering


\begin{tabular}{|c|E|c|}
\hline
&  & {Lorem Ipsum} \\ 
\hline
Lorem1 & Ipsum1 & \RotText{Lorem3 Ipsum3} \\
\hline
\end{tabular}

\lipsum

\begin{tabular}{|c|E|c|}
\hline
&  & {Lorem Ipsum} \\ 
\hline
\vspace{-10pt}{Lorem1} & Ipsum1 & \RotText{Lorem3 Ipsum3} \\
\hline
\end{tabular}

\end{document}
5

Add [origin=c] to the \rotatebox:

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{lipsum}

\newcolumntype{E}{>{\centering\arraybackslash}m{7cm}}
\newcommand\RotText[1]{%
  \rotatebox[origin=c]{90}{\parbox{2.6cm}{\fontsize{9}{9}\selectfont\centering#1}}}

\begin{document}

{
\centering
\begin{tabular}{|c|E|c|}
\hline
&  & {Lorem Ipsum} \\ 
\hline
Lorem1 & Ipsum1 & \RotText{Lorem3 Ipsum3} \\
\hline
\end{tabular}
}

\end{document}

Notice also that I moved the font size change commands inside the argument of the \parbox to make sure its effect is kept local.

enter image description here

In a comment is has been requested to change slightly the shape of the table:

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{lipsum}

\newcolumntype{E}{>{\centering\arraybackslash}m{7cm}}
\newcommand\RotText[1]{%
  \rotatebox[origin=c]{90}{\parbox{2.6cm}{\fontsize{9}{9}\selectfont\centering#1}}}

\begin{document}

{
\centering
\begin{tabular}{|c|E|c|}
\cline{3-3}
\multicolumn{1}{c}{} &  & {Lorem Ipsum} \\ 
\hline
Lorem1 & Ipsum1 & \RotText{Lorem3 Ipsum3} \\
\hline
\end{tabular}
}

\end{document}

enter image description here

  • @sphere You're welcome! I updated my answer with a modification that could be of interest for you. – Gonzalo Medina Mar 18 '14 at 20:56
  • How can I get rid of the first two cells as well so that the table looks like this: _| shape – Veridian Mar 18 '14 at 21:04
  • @sphere Please see my updated naswer. Is it something like that what you need? – Gonzalo Medina Mar 18 '14 at 21:09

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.