1

I'm trying to align my table text vertically:

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array,pifont,xcolor}
\newcolumntype{C}[3]{@{\hspace*{#1}}>{\centering\arraybackslash}m{#2}@{\hspace*{#3}}}
\newcolumntype{R}[2]{>{\raggedleft\arraybackslash}m{#1}@{\hspace*{#2}}}
\newcolumntype{L}[2]{@{\hspace*{#1}}>{\raggedright\arraybackslash}m{#2}}
\newcommand{\fajfka}{\textcolor[RGB]{0,166,79}{\ding{51}}}
\newcommand{\krizek}{\textcolor[RGB]{237,27,35}{\ding{55}}}
\newcommand{\degC}{$^\circ$C}
\begin{document}

\begin{tabular}{
  |R{70pt}{5pt}
  *{9}{|C{0pt}{20pt}{0pt}}|}
  \hline
  \multicolumn{1}{|C{6pt}{70pt}{0pt}|}{\textbf{\o\,\,= 2mm}} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & \textbf{v} \\[4pt]
  \cline{1-10}
  300\degC & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\[4pt]
  \cline{1-9}
  290\degC & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\[4pt]
  \cline{1-9}
  280\degC & \krizek & \krizek & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\[4pt]
  \cline{1-9}
  270\degC & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek \\[4pt]
  \cline{1-9}
  \textbf{t {[}\degC{]}} \\[4pt]
  \cline{1-1}
\end{tabular}

\end{document}

table

As seen, last visible column cell resp. last visible row cells are not vertically centered. Those can be also centered only if there are visible some other cell borders in those column, row.
How can I vertically center text in every visible cell?

Werner
  • 603,163
user46581
  • 575
  • use p not m or use a final &\multicolumn{1}{}\\ to make an empty cell with no rule rather than leave the row short with a m cell at the end – David Carlisle Oct 18 '14 at 20:38
  • basically I think this is a duplicate of this question, see Frank's answer: http://tex.stackexchange.com/questions/68732/vertical-alignment-in-table-m-column-row-size-problem-in-last-column/174166#174166 – David Carlisle Oct 18 '14 at 20:41

1 Answers1

6

m columns and [..] argument to \\ work in well specified ways, but they don't work well together or how people always expect. I'd avoid both here:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array,pifont,xcolor}
\newcolumntype{C}[3]{@{\hspace*{#1}}>{\centering\arraybackslash}p{#2}@{\hspace*{#3}}}
\newcolumntype{R}[2]{>{\raggedleft\arraybackslash}p{#1}@{\hspace*{#2}}}
\newcolumntype{L}[2]{@{\hspace*{#1}}>{\raggedright\arraybackslash}p{#2}}
\newcommand{\fajfka}{\textcolor[RGB]{0,166,79}{\ding{51}}}
\newcommand{\krizek}{\textcolor[RGB]{237,27,35}{\ding{55}}}
\newcommand{\degC}{$^\circ$C}
\begin{document}

{\renewcommand\arraystretch{1.5}
\begin{tabular}{
  |R{70pt}{5pt}
  *{9}{|C{0pt}{20pt}{0pt}}|}
  \hline
  \multicolumn{1}{|C{6pt}{70pt}{0pt}|}{\textbf{\o\,\,= 2mm}} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & \textbf{v} \\
  \cline{1-10}
  300\degC & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\
  \cline{1-9}
  290\degC & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\
  \cline{1-9}
  280\degC & \krizek & \krizek & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka & \fajfka \\
  \cline{1-9}
  270\degC & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek & \krizek \\
  \cline{1-9}
  \textbf{t {[}\degC{]}} \\
  \cline{1-1}
\end{tabular}}

\end{document}
David Carlisle
  • 757,742
  • 1
    Using the \diameter symbol from wasysymbol would look better, in my opinion (exists in boldmath). – Bernard Oct 18 '14 at 21:13