Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
    
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 4 '12 at 8:56
1  
@Andy: Use \rotatebox{-90}{\parbox{2cm}{Longitude \\ at a location}}. –  Harish Kumar Aug 4 '12 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.