在下面的代码中,我能够生成一定宽度的灰色虚线垂直线。我想用虚线替换实线。我尝试:
使用该arydshln
包添加,但会导致错误。
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{lscape}
\usepackage{geometry}
\usepackage{colortbl}
\usepackage{tcolorbox}
\geometry{left=2mm,right=2mm}
\geometry{top=3mm,bottom=3mm}
\newcolumntype{?}{!{\color{gray}\vrule width 0.5pt}}
\begin{document}
\begin{table}
\caption{Caption}
\begin{tabularx}{0.4\textwidth}{>{\hsize=\hsize}X?>{\hsize=\hsize}X}
\hline\\[0.2pt]
A & B\\
D & E\\
\end{tabularx}
\label{table1}
\end{table}
\end{document}
答案1
\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{arydshln}
\begin{document}
\begin{table}
\caption{Caption}
\arrayrulecolor{gray}
\begin{tabularx}{0.4\textwidth}{X:X}
\arrayrulecolor{black}
\hline\\[0.2pt]
A & B\\
D & E\\
\end{tabularx}
\label{table1}
\end{table}
\end{document}
答案2
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\tikzset
{
dashed 1/.style =
{
red ,
dash pattern = on 2pt off 3pt ,
line width = 1 pt
} ,
dashed 2/.style =
{
blue ,
dash pattern = on 1pt off 1pt ,
line width = 2pt
}
}
\begin{NiceTabular}{wc{2cm}wc{2cm}}
\hline
A & B\\
D & E\\
\CodeAfter
\begin{tikzpicture}
\draw [dashed 1] (row-1-|col-2) -- (row-3-|col-2) ;
\draw [dashed 2] (row-1-|col-3) -- (row-3-|col-3) ;
\draw [dashed 1] (row-2-|col-1) -- (row-2-|col-3) ;
\draw [dashed 2] (row-3-|col-1) -- (row-3-|col-3) ;
\end{tikzpicture}
\end{NiceTabular}
\end{document}