6

I want to align the text of one of my tables like this:

enter image description here

However, I got this:

enter image description here

The header of the table are centered and rotated (in case of the first column header) and the rest of the text are aligned to the left (second column) and right (rest of the columns).

So, because I'm new in this, I'm doing some bad techniques of LaTeX programming in LyX with my LyX file.

6

Each cell that should be set in a different alignment compared to the rest of the column in that table needs a specific Multicolumn formatting. Do achieve this, right-click in the cell of interest and select More... > Multicolumn:

enter image description here

Now you can format the centering in the regular way using the Table toolbar:

enter image description here

I've also rotated the first entry by 90 degrees using the following ERT:

enter image description here

Your output should now resemble:

enter image description here

6
  • Thanks, was very useful. However, I applied the instruction \cellcolor{lightgray}\multirow{-10}*{\rotatebox[origin=c]{90}{\itshape Instances}} in other table but I got this error: link I don't know if it is for the column merged in the bottom of the table. Thanks for the help – ArCiGo Jun 17 '14 at 20:58
  • @ArCiGo: Someone removed your LyX file. Now this post will help future visitors even less. You need to add \usepackage{graphicx} to your LaTeX Preamble. – Werner Jun 17 '14 at 21:05
  • I didn't post my file in PasteBin (the person who edited the post removed my link from Mediadire). I'm going to edit the link of my post. Why in this case we don't use the package graphicx, but in other cases we use it? – ArCiGo Jun 17 '14 at 21:20
  • @ArCiGo: graphicx provides functionality for the inclusion of pictures, but also other scaling/rotating options. I edited the original post, and made it "never expire" on PasteBin. It didn't seem to work then... – Werner Jun 17 '14 at 21:24
  • Thanks for the help. Sorry for no thank you on time. I made the table. One last question: how can centralize the text of the header in the cell independent of the number of rows and number of words and that this does not protrude from the cell? – ArCiGo Jun 28 '14 at 3:52
1

This is (almost) a solution using xcolor, colortbl, hhline, makecell and cellspace. However there remains in the bottom multirow a small zone that is not coloured, along the vertical line – and I don't understand. Nevertheless, here is the code, in the hope someone will improve it:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier, heuristica}
\usepackage{graphicx}
\usepackage{array, multirow}
\usepackage{colortbl}
\usepackage[x11names]{xcolor}
\usepackage{hhline}
\usepackage{makecell}
\renewcommand\theadfont{\itshape}

\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}

\begin{document}

\begin{table}[h]
  \centering
  \begin{tabular}{c|Sl|*{4}{r|}}
\rowcolor{LightSteelBlue4!10!} \thead{\rotatebox{90}{Instances}} & \thead{Algorithm} & \thead{Size of the\\ solution set} & \thead{Non-dominated\\ solutions to\\ Problem 13 in \\ $ O₁ \cup O₂ $} & \thead{Non-strictly-\\outranked\\ solutions in \\$ O₁ \cup O₂ $} & \thead{Non-dominated\\ solutions to \\ Problem 15 in \\ $ O₁ \cup O₂ $} \\
     \hline
\multirowcell{2}{1} & SS-PPS & 4996 & 4819 & 10 & 0 \\
 \hhline{~|-----} \hhline{~|-----}
 & NO-ACO II & 19 & 19 & 19 & 1 \\
     \hline
\rowcolor{LightSteelBlue4!10!}\multirowcell{2}{2} & SS-PPS & 4997 & 4878 & 12 & 0 \\
 \hhline{~|-----} \hhline{~|-----}
 \rowcolor{LightSteelBlue4!10!}{} & NO-ACO II &15 & 15 & 15 & 1 \\
     \hline
  \end{tabular}%
\end{table}

\end{document} 

enter image description here

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.