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?

2

1 Answer 1

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}
1
  • 1
    Using the \diameter symbol from wasysymbol would look better, in my opinion (exists in boldmath).
    – Bernard
    Oct 18, 2014 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .