0

I have a table where I want all the cells to be vertically centred. I added the following line

\renewcommand\tabularxcolumn[1]{m{#1}}

according to another post but I got inconsistent results with some cells that are centred but some not : enter image description here

The bicycle (contrary to the pedestrian) is not centred, and the PFG is stuck on the top line. How can I make everything vertically centred?

Here is the code:

\begin{table}
    \centering
    \caption{to do}
    \label{tab:law}
    \begin{tabularx}{0.49\textwidth}{cX|XXX}
    \toprule[1.5pt]
     & &  Japan &  Germany &  France \\ 
    \midrule[1.5pt]
    \multirow{2}{*}{\usymH{1F6B8}{12pt}} & Fine for red light violation & x & y & z \\
    \cline{2-5}
     {} & PFG & - & - & - \\
     \midrule[1.5pt]
     \multirow{2}{*}{\usymH{1F6B4}{12pt}} & Driving on sidewalk & x & y & z \\
    \cline{2-5}
     {} & Fine for red light violation & - & - & - \\
    \bottomrule[1.5pt]
    \end{tabularx}
\end{table}

PS: bonus question, is there a way to make the vertical line continuous?

1 Answers1

3

It is easy peasy with tblr environment of the new LaTeX3 package tabularray:

\documentclass{article}

\usepackage{utfsym} \usepackage{caption} \usepackage{tabularray} \UseTblrLibrary{booktabs}

\begin{document}

\begin{table} \centering \caption{to do} \label{tab:law} \begin{tblr}{width=0.68\textwidth,colspec={cX[l,m]|X[l,m]X[l,m]X[l,m]}} \toprule[1.5pt] & & Japan & Germany & France \ \midrule[1.5pt] \SetCell[r=2]{l}\usymH{1F6B8}{12pt} & Fine for red light violation & x & y & z \ \cline{2-5} & PFG & - & - & - \ \midrule[1.5pt] \SetCell[r=2]{l}\usymH{1F6B4}{12pt} & Driving on sidewalk & x & y & z \ \cline{2-5} & Fine for red light violation & - & - & - \ \bottomrule[1.5pt] \end{tblr} \end{table}

\end{document}

enter image description here

L.J.R.
  • 10,932