1

I am trying to create a table like this one here: enter image description here

The problem I have is that it requires a lot of finite tuning for each cell to be centered, and I'm planning to add more rows for different kanji symbols (which may have more subrows for each (K) and (O) row. Is there a way to configure the alignment programatically?

Here is the code for the table I showed (must be compiled with XeLaTeX compiler):

\documentclass[12pt]{article}
\usepackage{xeCJK}
\usepackage{ruby}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{array}

\renewcommand{\rubysep}{-4ex}
\newcommand{\mr}[2]{\multirow[c]{#1}{*}{#2}}
\newcommand\Bstrut{\rule[-2.5ex]{0pt}{0pt}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
% I added more height to the cells to allow the japanese characters to have space for the text below them 
\renewcommand{\arraystretch}{2}
\pagestyle{empty}
\begin{document}
\begin{table}[!ht]

\hspace{-2cm}\begin{tabular}{|M{1.5cm}|m{3cm}|M{2cm}|M{2.8cm}|M{3cm}|M{2.8cm}|}
    \hline
    % The multicolumn commands used here are needed to align vertically the cells
    \multicolumn{1}{|c|}{漢字}  & \multicolumn{1}{c|}{Explicación} & \multicolumn{2}{c|}{くんよみ(K)•おんよみ(O)} & \multicolumn{1}{c|}{Palabras} & \multicolumn{1}{c|}{Significado}\\
    \hline
    \hline
    \multirow[c]{7}{*}{人} & \multirow[c]{7}{3cm}[0.2pt]{Persona. \newline Indica el lugar de procedencia de la persona. \newline Contador de personas.} & K & ひと  & \ruby{人}{ひと}\Bstrut & Persona\\
    \cline{3-6}
    & & \multirow{3}{*}[0.2cm]{O} & ジン & アルゼンチン\ruby{人}{じん}\Bstrut & Argentino\\
    \cline{4-6}
    & & & ニン & \ruby{三}{3}\ruby{人}{にん} & Contador: Tres personas\\
    \cline{3-6}
    & & \multicolumn{2}{c|}{\multirow{3}{*}{Excepciones}} & \ruby{一人}{ひとり} & Contador: Una persona\\
    \cline{5-6}
    & & \multicolumn{2}{c|}{} & \ruby{二人}{ふたり} & Contador: Dos personas\\
    \hline
\end{tabular}
\end{table}
\end{document} 
  • welcome to tex.se! (i) this table i already sow here ... and answer(s) to it solve similar issues as you have (ii) your table is to wide to be fit in text area. you should consider to enlarge \textwidth (iiI) if you have more lines for row with K, than also for this row use the \multirow as you use for row with O. – Zarko Dec 6 '18 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.