4

I would like to generate a table that has each column header displayed sideways. For example:

\documentclass{article}
\usepackage{rotating}
\begin{document}
    \begin{sidewaystable}
    \begin{tabular}{cccc}
    Name & Location & Latitude & Longitude\\
    name1 & loc1 & lat1 & lon1\\
    name2 & loc2 & lat2 & lon2\\
    \end{tabular}
    \end{sidewaystable}
\end{document}

From this example I would like the first 4 arguments (i.e. the column headers) to be orientated vertically. How can this be achieved?

David Carlisle
  • 757,742
Andy
  • 43

1 Answers1

4

Like in this answer you can use the \rotatebox:

\documentclass{article}
\usepackage{rotating}
\begin{document}
    \begin{sidewaystable}
    \begin{tabular}{cccc}
    \rotatebox{-90}{Name} & \rotatebox{-90}{Location} & \rotatebox{-90}{Latitude} & \rotatebox{-90}{Longitude}\\
    name1 & loc1 & lat1 & lon1\\
    name2 & loc2 & lat2 & lon2\\
    \end{tabular}
    \end{sidewaystable}
\end{document}

resulting output

David Carlisle
  • 757,742
bodo
  • 6,228
  • Great. One more question: say if one of the cell entries was really long for example if instead of 'Latitude' I would have 'Latitude at a location', how could I separate that cell entry over two lines? So have 'Latitude' and then 'at a location' in the same cell but extending over two lines? – Andy Aug 04 '12 at 08:56
  • 1
    @Andy: Use \rotatebox{-90}{\parbox{2cm}{Longitude \\ at a location}}. –  Aug 04 '12 at 16:00