I want to make a table with several columns, two of them are long horizontal lines, as appears in the image. Could anyone help me?

Asked
Active
Viewed 935 times
0
Manolo
- 13
-
I believe this thread should help you out: https://tex.stackexchange.com/questions/371286/draw-a-horizontal-line-in-latex – likethevegetable Dec 16 '19 at 20:21
2 Answers
2
You can use a TikZ matrix of nodes. Please note that it is a bit inconvenient to answer questions which only have a screen shot. I am not good at typing, so I just copied one row, you will need to change the texts yourself.
\documentclass{article}
\usepackage{booktabs}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{table}[htb]
\caption{A table.}
\centering\vspace*{0.2em}
\begin{tabular}{c}
\toprule
\begin{tikzpicture}[font=\sffamily]
\matrix[matrix of math nodes,nodes={anchor=center},
column sep={width("hexagonal")+2em},
execute at end matrix={
\foreach \YY in {2,...,\the\pgfmatrixcurrentrow}
{\foreach \XX in {2,...,\the\pgfmatrixcurrentcolumn}
{\draw (\tikzmatrixname-\YY-\the\numexpr\XX-1) --
(\tikzmatrixname-\YY-\XX);} }}] (mat){
\mathsf{D}_{3d} & \mathsf{O}_{h} & \mathsf{D}_{4h} \\[2.5em]
\mathsf{A}_{1g} & \mathsf{A}_{1g} & \mathsf{A}_{1g}\\
\mathsf{A}_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}+E_{1g}\\
\mathsf{A}_{1g}+E_{1g} & \mathsf{A}_{2g} & \mathsf{A}_{1g}+E_{1g}\\
\mathsf{A}_{2g}+E_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}\\
\mathsf{A}_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}\\[1.5em]
\mathsf{A}_{1g} & \mathsf{A}_{1g} & \mathsf{A}_{1g}\\
\mathsf{A}_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}+E_{1g}\\
\mathsf{A}_{1g}+E_{1g} & \mathsf{A}_{2g} & \mathsf{A}_{1g}+E_{1g}\\
\mathsf{A}_{2g}+E_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}\\
\mathsf{A}_{1g} & \mathsf{A}_{2g} & \mathsf{B}_{1g}\\
};
\draw[latex-latex] (mat-1-1) -- node[above]{trigonal}
node[below,align=center]{distortion\\[1ex] (along $\mathsf{C}_3$)} (mat-1-2);
\draw[latex-latex] (mat-1-2) -- node[above]{tetragonal}
node[below,align=center]{distortion\\[1ex] (along $\mathsf{C}_4$)} (mat-1-3);
\end{tikzpicture}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
EDIT: Made the sizes of the entries different to show that the lines really go to these entries and do not stop at a common horizontal point.
2
An option, if lines are okay to stay within their column:
\documentclass{article}
\usepackage{booktabs,mathtools,xhfill}
\newcommand{\ch}[2]{\ensuremath{\mathrm{#1}_{\mathrm{#2}}}}
\newcommand{\fromto}[3]{#1 & \xrfill[.5ex]{.4pt} & #2 & \xrfill[.5ex]{.4pt} & #3}
\begin{document}
\begin{table}
\centering
\caption{A table}
\begin{tabular}{ c @{\,} c @{\,} c @{\,} c @{\,} c }
\toprule
\ch{D}{3d} &
$\xleftrightarrow[\substack{\text{distortion} \\ \text{(along \ch{C}{3})}}]{\text{trigonal}}$ &
\ch{O}{h} &
$\xleftrightarrow[\substack{\text{distortion} \\ \text{(along \ch{C}{4})}}]{\text{tetragonal}}$ &
\ch{D}{4h} \\
\addlinespace
\fromto{\ch{A}{1g}}{\ch{A}{1g}}{\ch{A}{1g}} \\
\fromto{\ch{A}{2g}}{\ch{A}{2g}}{\ch{B}{1g}} \\
\fromto{\ch{E}{g}} {\ch{E}{g}} {$\ch{A}{1g} + \ch{B}{1g}$} \\
\fromto{$\ch{A}{2g} + \ch{E}{g}$}{\ch{T}{1g}}{$\ch{A}{2g} + \ch{E}{g}$} \\
\fromto{$\ch{A}{1g} + \ch{E}{g}$}{\ch{T}{2g}}{$\ch{B}{2g} + \ch{E}{g}$} \\
\addlinespace
\fromto{\ch{A}{1u}}{\ch{A}{1u}}{\ch{A}{1u}} \\
\fromto{\ch{A}{2u}}{\ch{A}{2u}}{\ch{B}{1u}} \\
\fromto{\ch{E}{u}} {\ch{E}{u}} {$\ch{A}{1u} + \ch{B}{1u}$} \\
\fromto{$\ch{A}{2u} + \ch{E}{u}$}{\ch{T}{1u}}{$\ch{A}{2u} + \ch{E}{u}$} \\
\fromto{$\ch{A}{1u} + \ch{E}{u}$}{\ch{T}{2u}}{$\ch{B}{2u} + \ch{E}{u}$} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Werner
- 603,163

