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'm not exactly sure how to format my LaTeX code for this website. So maybe someone can help me with that... I'm having trouble with a table in LaTeX:

  1. In the cell that says "Dimension of Sample", the text goes outside the box.

  2. I would like the 1,2,3 of the sample dimensions to be centered in the cells vertically

  3. I would like the main portion of the table entries to be left aligned without affecting the alignment for the rest of the table.

Any help is appreciated!

\documentclass{report}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|c|}
\cline{3-6} 
\multicolumn{1}{c}{} &  & \multicolumn{4}{c|}{\textbf{Dimension of Measurement}} & \multicolumn{1}{c}{\multirow{2}{*}{}}\tabularnewline
\cline{3-6} 
\multicolumn{1}{c}{} &  & \textbf{0} & \textbf{1} & \textbf{2} & \textbf{3}  \tabularnewline
\hline

\multirow{3}{*}{\rotatebox[origin=c]{90}{\textbf{Dimension of Sample}}} & \textbf{1} & \shortstack{P10\\No of fractures\\per unit length\\of borehole} & \shortstack{P11\\Length of\\fractures per\\unit length} &  &  & \textbf{\shortstack{Linear\\Measures}}\tabularnewline
\cline{2-7}

 & \textbf{2} & \shortstack{P20\\No of fractures\\per unit\\area} & \shortstack{P21\\Length of\\fractures per\\unit area} & \shortstack{P22\\Area of\\fractures per\\unit area} &  & \textbf{\shortstack{Areal\\Measures}}\tabularnewline
\cline{2-7}

 & \textbf{3} & \shortstack{P30\\No of fractures\\per unit\\volume} &  & \shortstack{P32\\Area of\\fractures per\\unit volume} & \shortstack{P33\\Volume of\\fractures per\\unit volume} & \textbf{\shortstack{Volumetric\\Measures}}\tabularnewline
\hline 
\multicolumn{2}{c|}{} & \textbf{Density} &  & \textbf{Intensity} & \textbf{Porosity} & \multicolumn{1}{c}{}\tabularnewline
\cline{3-6} 
\end{tabular}
\end{document}
share|improve this question
add comment

1 Answer

With the aid of the array package (provides > and < syntax) and the own defined macro \mystack you can get there quite easily.

Note, that the whole table is to wide for the standard report margins. I did not try to correct that. (Orienting the table to landscape would help here.)

Notes:

Code

\documentclass{report}
\usepackage{graphicx,multirow,array}
\newcommand*{\mystack}[2][l]{\begin{tabular}[c]{@{}#1@{}}#2\end{tabular}}
\usepackage[pass,showframe]{geometry}
\begin{document}
\noindent
\begin{tabular}{|c|>{\bfseries}c|c|c|c|c|>{\bfseries}c|} \cline{3-6}
    \multicolumn{1}{c}{}                                                    &   & \multicolumn{4}{c|}{\textbf{Dimension of Measurement}}                                                                                                                                                                                      & \multicolumn{1}{c}{}               \\ \cline{3-6}
    \multicolumn{1}{c}{}                                                    &   & \textbf{0}                                                      & \textbf{1}                                              & \textbf{2}                                            & \textbf{3}                                              & \multicolumn{1}{c}{}               \\ \hline
    \multirow{3}{*}{\rotatebox[origin=c]{90}{\textbf{Dimension of Sample}}} & 1 & \mystack{P10\\ No of fractures\\ per unit length\\ of borehole} & \mystack{P11\\ Length of\\ fractures per\\ unit length} &                                                       &                                                         & \mystack[c]{Linear\\ Measures}     \\ \cline{2-7}
                                                                            & 2 & \mystack{P20\\ No of fractures\\ per unit\\ area}               & \mystack{P21\\ Length of\\ fractures per\\ unit area}   & \mystack{P22\\ Area of\\ fractures per\\ unit area}   &                                                         & \mystack[c]{Areal\\ Measures}      \\ \cline{2-7}
                                                                            & 3 & \mystack{P30\\ No of fractures\\ per unit\\ volume}             &                                                         & \mystack{P32\\ Area of\\ fractures per\\ unit volume} & \mystack{P33\\ Volume of\\ fractures per\\ unit volume} & \mystack[c]{Volumetric\\ Measures} \\ \hline
    \multicolumn{2}{c|}{}                                                       & \textbf{Density}                                                &                                                         & \textbf{Intensity}                                    & \textbf{Porosity}                                       & \multicolumn{1}{c}{}               \\ \cline{3-6}
\end{tabular}

Output

Output

share|improve this answer
add comment

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.