tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Center-aligned hline and vline segments of different widths

Open lvjr opened this issue 1 year ago • 0 comments

At present, line segments of different widths in a hline/vline aligns at the bottom/left. It would be better to set center alignment for them. The following example demonstrates the planned result using nicematrix package:

\documentclass{article}
\usepackage{tabularray,nicematrix,tikz}
\begin{document}

\section{Current Result}

\begin{tblr}{
  hlines = {1}{1pt}, hlines = {2}{2pt}, hlines = {3}{3pt},
}
  Alpha   & Beta  & Gamma  \\
  Epsilon & Zeta  & Eta    \\
  Iota    & Kappa & Lambda \\
\end{tblr}
\qquad
\begin{tblr}{
  vlines = {1}{1pt}, vlines = {2}{2pt}, vlines = {3}{3pt},
}
  Alpha   & Beta  & Gamma  \\
  Epsilon & Zeta  & Eta    \\
  Iota    & Kappa & Lambda \\
\end{tblr}

\section{Future Result}

\renewcommand\arraystretch{1.5}

\begin{NiceTabular}{lll}
  Alpha   & Beta  & Gamma  \\
  Epsilon & Zeta  & Eta    \\
  Iota    & Kappa & Lambda \\
\CodeAfter
\begin{tikzpicture}
\foreach \i in {1,2,3,4} {
  \draw[line width=1pt] (\i-|1) -- (\i-|2);
  \draw[line width=2pt] (\i-|2) -- (\i-|3);
  \draw[line width=3pt] (\i-|3) -- (\i-|4);
}
\end{tikzpicture}
\end{NiceTabular}
\qquad
\begin{NiceTabular}{lll}
  Alpha   & Beta  & Gamma  \\
  Epsilon & Zeta  & Eta    \\
  Iota    & Kappa & Lambda \\
\CodeAfter
\begin{tikzpicture}
\foreach \i in {1,2,3,4} {
  \draw[line width=1pt] (1-|\i) -- (2-|\i);
  \draw[line width=2pt] (2-|\i) -- (3-|\i);
  \draw[line width=3pt] (3-|\i) -- (4-|\i);
}
\end{tikzpicture}
\end{NiceTabular}

\end{document}

image

This change is a prerequisite for the smash option (issue #215) and tikz library (issue #29).

lvjr avatar Jan 14 '23 02:01 lvjr