2

I had a simple example that worked well but since reinstalling MikTeX, I can't center A in the middle of the cell anymore

\newcolumntype{C}{ >{\centering\arraybackslash} m{0.5\textwidth} }

\begin{tabular}{|C|}
    \hline
    A\\[50pt]
    \hline
\end{tabular}

A not vertically centered

And a MWE more complete :

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{array}

\begin{document}
\newcolumntype{C}{ >{\centering\arraybackslash} m{0.45\textwidth} }
\newcolumntype{D}{ >{\centering\arraybackslash} m{0.45\textwidth} }

\begin{tabular}{|C|D|@{}m{0pt}@{}}
    \hline
    A & B & \\[10pt]
    \hline
    \begin{itemize}
        \item bla
        \item bla
        \item bla
    \end{itemize} &
    \begin{tabular}{cc}
        a & b \\
        c & d \\
        e & f 
    \end{tabular}
 \\ \hline
\end{tabular}
\end{document}

Something has changed or am I making a mistake somewhere? Thanks in advance.

8
  • 3
    Because you say so: remove [50pt] after line terminator. for space around A, you need different approach, for example with use of the makecell or cellspace package.
    – Zarko
    Commented Jan 30, 2020 at 11:07
  • The goal is to draw a table with the first row height is x and the second row height y. The approach you proposed is still relevant ?
    – rhum187
    Commented Jan 30, 2020 at 11:18
  • (i) please provide MWE with your table, without it is difficult to imagine, what you like to have, (ii) cells height is mostly determined by cells contents, what should hapen if contents is higher than x?
    – Zarko
    Commented Jan 30, 2020 at 12:54
  • I've added a MVE in my question. I hope it's a bit clearer ;)
    – rhum187
    Commented Jan 30, 2020 at 13:29
  • 2
    well, this is only code fragment, not an MWE. Please add \documentclass, preamble with necessary packages for table and \end{document}.
    – Zarko
    Commented Jan 30, 2020 at 13:45

2 Answers 2

2

I would reformat your table in the following (however, I'm not sure, what you like to have):

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage{enumitem}  
\usepackage{ragged2e}                           % <---
\usepackage{array, makecell}
\renewcommand\theadfont{\normalsize\bfseries}   % <---
\newcolumntype{L}[1]{ >{\csname @minipagetrue\endcsname% <---
                        \RaggedRight\hspace{0pt}}m{#1} } 

\begin{document}
    \begin{table}[ht]
    \centering
    \setlist[itemize]{nosep,                    % <--- list setup
                      leftmargin=*,
                      label=\textbullet,    
                      before=\vspace{-0.6\baselineskip},
                      after =\vspace{-0.6\baselineskip}
                      }
\begin{tabular}{| L{0.45\linewidth} | L{0.45\linewidth}|}
    \hline
\thead{A}       &   \thead{B}   \\
    \hline
\begin{itemize}
    \item bla
    \item bla
    \item bla
\end{itemize}   &   \vspace{-0.6\baselineskip}% <---
                    \begin{tabular}{@{} cc @{}}
                a & b \\
                c & d \\
                e & f
                    \end{tabular}   \\ 
    \hline
\end{tabular}
    \end{table}
\end{document}
1
  • Thank you Zarko
    – rhum187
    Commented Feb 3, 2020 at 8:08
1

Quick and dirty trick:

mwe

\documentclass[10pt,a4paper]{article}
\usepackage{array,xcolor}
\begin{document}
\color{gray!50}
1

2

3 --- --- --- --- ---> 

4

5
\color{black}

\vspace{-5\baselineskip}

\newcolumntype{C}{ >{\centering\arraybackslash}m{0.45\textwidth}}
\begin{tabular}{|C|C|}
\hline
\rule[-25.5pt]{0em}{60pt}  A & \rule[-25.5pt]{0em}{60pt} B \\
\hline
\begin{itemize}
        \item bla
        \item bla
        \item bla
\end{itemize} & \renewcommand\arraystretch{1}
\begin{tabular}{cc}
        a & b \\
        c & d \\
        e & f 
\end{tabular} \\ \hline
\end{tabular}
\end{document}

You must log in to answer this question.

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