1

I have some really specific requirements for my table's occurrence in my master's thesis (scrbook). I found some help in this forum but there is not "the" solution for me. Below you can see my actual workaround for tables:

    \begin{table}[h]
      \caption{xyz}
      \label{xyz}
      \centering\sffamily
        \begin{tabularx}{1.0\textwidth}{|X|X|X|}
            \hline
            \rowcolor[gray]{0.8}
            \multicolumn{1}{|c|}{\textbf{xyz}} & \multicolumn{1}{|c|}{\textbf{xyz}} & \multicolumn{1}{c|}{\textbf{xyz}} \\ \hline
            \textbf{xyz} & xyz & xyz \\ \hline
            \textbf{xyz} & xyz & xyz \\ \hline
            \textbf{xyz} & xyz & xyz \\ \hline
            \textbf{xyz} & xyz & xyz \\ \hline
        \end{tabularx}
    \end{table}

My institute’s requirements are listed below if they are not already implemented.

(1) The first row's height has to be 1cm, the text should be boldfaced plus horizontal AND vertical centered.

(2) Text in the first column should be vertical centered but horizontal left aligned (except of the first cell where formatting (1) applies).

(3) The remaining text should be horizontal left and vertical top aligned.

Further I have set my global line spread by using

    \renewcommand{\baselinestretch}{1.12}

Within my table I would like to have single spacing, but using the \setspace-command is not an option. Is it possible to realize all this? I already thought about preparing tables as pdfs and input them as graphics...

I hope i described my problem understandable ;) Else I will give it a second try!!

Cheers, Julian

  • 1
    Something to start with: \newcommand*{\strangeRequirementOfMyInstituteWhichIHaveToPutInEveryFirstCell}{\rule[-11pt]{0pt}{1cm}}\renewcommand{\arraystretch}{.9}. The vertical centring of the first row seems to be difficult... – LaRiFaRi Aug 13 '15 at 7:50
0

Do you like to have something like this: enter image description here

I didn't measure height of the first row (it should be approximately 1cm), for other rows I understand that they haven't request for minimal height of 1cm. In code I use thead from the makecell package. With renewcommad I select boldface fonts for them, boldface fonts in the first column is determined by option of the first column.

Vertical centering in the cells of the first column is achieved by \multirowcell, where you need to determine number of lines in the highest cell in the row.

Code:

\documentclass{article}
    \usepackage[svgnames,table]{xcolor}
    \usepackage{array,makecell,multirow,tabularx}
\renewcommand\theadfont{\bfseries}
\renewcommand{\arraystretch}{1.2}% for global setting 
                                 % (amount select according to your taste) 
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{5pt}%

\begin{document}
    \begin{table}[h]
%\renewcommand{\arraystretch}{1.2}% only for local use 
      \caption{xyz}
      \label{xyz}
      \centering\sffamily
        \begin{tabularx}{\textwidth}{|>{\bfseries}X|X|X|}
            \hline
            \rowcolor[gray]{0.8}
\thead{xyz} &   \thead{xyz} &   \thead{xyz} \\  \hline
\multirowcell{1}{xyz}   &   xyz         &   xyz         \\  \hline
\multirowcell{1}{xyz}   &   xyz         &   xyz         \\  \hline
\multirowcell{1}{xyz}   &   xyz         &   xyz         \\  \hline
\multirowcell{2}{xyz}   % {2}: number of lines in cell  
                        &   xyz\newline
                            xyz         &   xyz         \\  \hline
        \end{tabularx}
    \end{table}
\end{document}
  • Only remaining question is how to change the line spacing within a table using the baselinestretch-command. Any suggestions?? – Julian Aug 14 '15 at 9:09
  • @Julian, just add \renewcommand{\arraystretch}{1.2 in preamble for global change of stretch or before table for lovcal table only. I will edit my answer with this. – Zarko Aug 14 '15 at 9:56

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.