TransWikia.com

Dashed vertical colored line with chosen width in tabularx

TeX - LaTeX Asked on January 14, 2021

In the code below, I was able to produce dashed grey vertical lines of a certain width. I want to replace the solid line by a dashed one. I tried to add : using the arydshln package, but it leads to error.

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.4textwidth}{>{hsize=hsize}X?>{hsize=hsize}X}
hline[0.2pt]
A & B
D & E
end{tabularx}
label{table1}
end{table}

end{document}

2 Answers

enter image description here

documentclass{article}
usepackage{tabularx}
usepackage[table]{xcolor}
usepackage{arydshln}

begin{document}

begin{table}
caption{Caption}
arrayrulecolor{gray}
begin{tabularx}{0.4textwidth}{X:X}
arrayrulecolor{black}
hline[0.2pt]
A & B
D & E
end{tabularx}
label{table1}
end{table}

end{document}

Answered by leandriis on January 14, 2021

enter image description here

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}

Answered by js bibra on January 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP