테이블 형식 환경의 연속 수직선

테이블 형식 환경의 연속 수직선

다음 코드를 사용하여 테이블을 만들었습니다.

\begin{tabular}{p{3cm}|p{3cm}|p{3cm}} 
  Symbol & Units & Quantity     \\  
\hline \hline
    $A$                 & m$^2$   & Area         \\
    $a$                 & m^{2}/s & Acceleration \\
    $F$                 & N       & Force        \\
    $l$                 & m       & Length       \\
    $u$                 & m/s     & Velocity
\end{tabular}

그 결과는 다음과 같습니다:

여기에 이미지 설명을 입력하세요

보시다시피, 수직선은 연속적이지 않습니다. 즉, 수직선이 수평선과 만날 때 간격이 있고 다시 두 번째 수평선 이후에는 수직선이 연속됩니다.

수직선의 간격을 원하지 않습니다. 나는 다음 그림과 같은 것을 원합니다.

여기에 이미지 설명을 입력하세요

원하는 결과를 얻으려면 코드에서 어떤 변경을 해야 하는지 알려주실 수 있나요?

답변1

원하는 연속 수직선을 얻으려면 패키지 \hhline{=|=|=}에서 사용할 수 있습니다 hhline. 다음 예에서는 siunitx단위에 대한 패키지 도 사용했습니다 .

다음 mwe에서는 세 가지 버전의 테이블을 추가했습니다. 첫 번째 항목에서는 방금 추가한 \hhlinesiunitx. 여기서 지수는 수평선에 닿습니다. 이를 방지하기 위해 cellspace셀 주변의 공백을 위해 패키지를 추가로 사용한 두 번째 테이블을 추가했습니다 . 그러나 개인적으로는 패키지의 수직선과 수평선이 없는 좀 더 컴팩트한 테이블을 선호합니다 booktabs. 이에 대한 예가 세 번째 표에 나와 있습니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{hhline}
\usepackage{siunitx}
\sisetup{per-mode=symbol}
\usepackage[column=0]{cellspace}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{\cellspacetoplimit}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{p{3cm}|p{3cm}|p{3cm}} 
  Symbol & Units & Quantity     \\  
\hhline{=|=|=}
    $A$                 & \si{\m\squared}       & Area         \\
    $a$                 & \si{\m\squared\per\s} & Acceleration \\
    $F$                 & \si{\N}               & Force        \\
    $l$                 & \si{\m}               & Length       \\
    $u$                 & \si{\m\per\s}         & Velocity
\end{tabular}

\bigskip

\begin{tabular}{0{p{3cm}}|0{p{3cm}}|0{p{3cm}}} 
  Symbol & Units & Quantity     \\  
\hhline{=|=|=}
    $A$                 & \si{\m\squared}       & Area         \\
    $a$                 & \si{\m\squared\per\s} & Acceleration \\
    $F$                 & \si{\N}               & Force        \\
    $l$                 & \si{\m}               & Length       \\
    $u$                 & \si{\m\per\s}         & Velocity
\end{tabular}

\bigskip

\begin{tabular}{lll} 
\toprule
  Symbol & Units & Quantity     \\  
\midrule
    $A$                 & \si{\m\squared}       & Area         \\
    $a$                 & \si{\m\squared\per\s} & Acceleration \\
    $F$                 & \si{\N}               & Force        \\
    $l$                 & \si{\m}               & Length       \\
    $u$                 & \si{\m\per\s}         & Velocity     \\
\bottomrule
\end{tabular}
\end{document}

답변2

{NiceTabular}를 사용 하면 nicematrix예상되는 출력을 직접 얻을 수 있습니다(그러나 테이블 디자인은 을 사용하는 booktabs것이 더 나을 것입니다).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{p{3cm}|p{3cm}|p{3cm}}[cell-space-top-limit=2pt]
  Symbol & Units & Quantity     \\  
\hline \hline
    $A$                 & m$^2$     & Area         \\
    $a$                 & m$^{2}$/s & Acceleration \\
    $F$                 & N         & Force        \\
    $l$                 & m         & Length       \\
    $u$                 & m/s       & Velocity
\end{NiceTabular}

\end{document}

여러 컴파일이 필요합니다( nicematrix내부적으로 PGF/Tikz 노드를 사용하기 때문에).

위 코드의 출력

관련 정보