0

I have recently started using LaTeX and I am having a bit of trouble creating a table. More specific creating vertical dashed lines.

As of now this what I have written:

 \usepackage{float}
 \usepackage{array}
 \usepackage{arydshln}
 \usepackage{multirow}
 \usepackage{amsbsy}
{\renewcommand{\arraystretch}{1.5}
\begin{table}[H]
\centering
\label{my-label}
\begin{tabular}{cc|c|c|cccccc|c}
&   &   &   & \multicolumn{5}{c}{\textbf{Coefficient}}  &   \\\cline{4-10}
\textbf{Iteration} & \textbf{B} & \textbf{Eq.} & \textbf{Z} & \textbf{$x_1$} & $\boldsymbol{x_2}$ & $\boldsymbol{x_3}$ & $\boldsymbol{x_4}$ & $\boldsymbol{x_5}$ & $\boldsymbol{x_6}$ & \textbf{RHS}  \\\hline
\multirow{4}{*}{0} &  Z     & (0) & 1 & -200  & -200  & -700  & 0     & 0     & 0     & 0    \\ 
                   &  $x_4$ & (1) & 0 & 2     & 1     & 3     & 1     & 0     & 0     & 22   \\\cdashline{5-11}
                   &   $x_5$ & (2) & 0 & 1     & 2     & 4     & 0     & 1     & 0     & 20   \\\cdashline{5-11}
                   &   $x_6$ & (3) & 0 & 1     & 1     & 1     & 0     & 0     & 1     & 10   \\\hline
\multirow{4}{*}{1} &  Z     & (0) & 1 & -25   & 150   & 0     & 0     & 175   & 0     & 3500                       \\\cdashline{5-11}
                   &  $x_4$ & (1) & 0 & 5/4   & -1/2  & 0     & 1     & -3/4  & 0     & 7    \\\cdashline{5-11}
                   &  $x_3$ & (2) & 0 & 1/4   & 1/2   & 1     & 0     & 1/4   & 0     & 5    \\
                   &  $x_6$ & (3) & 0 & 3/4   & 1/2   & 0     & 0     & -1/4  & 1     & 5    \\\hline
\multirow{4}{*}{2} &  Z     & (0) & 1 & 0     & 140   & 0     & 20    & 160   & 0     & 3640 \\
                   &  $x_1$ & (1) & 0 & 1     & -2/5  & 0     & 4/5   & -3/5  & 0     & 28/5 \\
                   &  $x_3$ & (2) & 0 & 0     & 3/4   & 1     & -1/5  & 2/5   & 0     & 18/5 \\
                   &  $x_6$ & (3) & 0 & 0     & 4/5   & 0     & -3/4  & 1/5   & 1     & 4/5 
\end{tabular}
\end{table}
}

I am trying to get to look a bit like this, but rather than hlines, I would like them to be dashlines:

enter image description here

4
  • Welcome to TeX.SE. Please help us to help you! Make your code snipped as small complete document with \documentclass{...} on the its beginning and \end{document}` on the end. It is not fun to search for missing part of your code ...
    – Zarko
    Commented Mar 2, 2017 at 10:04
  • have see here : tex.stackexchange.com/a/291848/71988
    – flav
    Commented Mar 2, 2017 at 10:17
  • Your code already produce on some place dash lines ... what is your problem? you like to have some numbers in boxes as show image? in this case see tex.stackexchange.com/questions/291872/…. Please clarify your question.
    – Zarko
    Commented Mar 2, 2017 at 10:18
  • If you simply want (vertical or horizontal) dashed lines see this: tex.stackexchange.com/questions/122301/…
    – CarLaTeX
    Commented Mar 2, 2017 at 10:30

1 Answer 1

2

I propose a solution with pstricks: the idea is to create two nodes in a row, and to connect them with an \ncbox node connection, with the relevant style. In addition, I change slightly the layout of the table so that it fits within a column.

    \documentclass[10pt, conference, letterpaper, svgnames]{IEEEtran}
    \usepackage{caption}%
 \usepackage{float}
 \usepackage{array}
 \usepackage{arydshln}
 \usepackage{multirow, rotating}
 \usepackage{amsbsy, bm}
 \usepackage{pst-node, auto-pst-pdf}
 \usepackage{lipsum}

     \begin{document}
\lipsum[1-2]

{\renewcommand{\arraystretch}{1.5}
\begin{table}[H]
\centering\small\renewcommand\tabcolsep{3.5pt}
\label{my-label}
\begin{postscript}
\begin{tabular}{c>{$}c<{$}|c|c|*{6}{>{$}c<{$}}|c@{\,}}
& & & & \multicolumn{5}{c}{\textbf{Coefficient}} & \\\cline{4-10}
\rotatebox{90}{\textbf{Iteration}} & \textbf{B} & \textbf{Eq.} & \textbf{Z} & \bm{x_1} & \bm{x_2} & \bm{x_3} & \bm{x_4} & \bm{x_5} & \bm{x_6} & \textbf{RHS} \\\hline
\multirow{4}{*}{0} & Z & (0) & 1 & -200 & -200 & -700 & 0 & 0 & 0 & 0 \\
                   & x_4 & (1) & 0 & 2 & 1 & 3 & 1 & 0 & 0 & 22 \\
                   & x_5 & (2) & 0 & \Rnode{N1}{1} & 2 & 4 & 0 & 1 & 0 & \Rnode{N2}{20} \\
                   & x_6 & (3) & 0 & 1 & 1 & 1 & 0 & 0 & 1 & 10 \\\hline
\multirow{4}{*}{1} & Z & (0) & 1 & -25 & 150 & 0 & 0 & 175 & 0 & 3500 \\
                   & x_4 & (1) & 0 & \Rnode{N3}{5/4} & -1/2 & 0 & 1 & -3/4 & 0 & \Rnode{N4}{7} \\
                   & x_3 & (2) & 0 & 1/4 & 1/2 & 1 & 0 & 1/4 & 0 & 5 \\
                   & x_6 & (3) & 0 & 3/4 & 1/2 & 0 & 0 & -1/4 & 1 & 5 \\\hline
\multirow{4}{*}{2} & Z & (0) & 1 & 0 & 140 & 0 & 20 & 160 & 0 & 3640 \\
                   & x_1 & (1) & 0 & 1 & -2/5 & 0 & 4/5 & -3/5 & 0 & 28/5 \\
                   & x_3 & (2) & 0 & 0 & 3/4 & 1 & -1/5 & 2/5 & 0 & 18/5 \\
                   & x_6 & (3) & 0 & 0 & 4/5 & 0 & -3/4 & 1/5 & 1 & 4/5
\end{tabular}
\psset{linewidth=0.4pt, linestyle=dashed, dash=4pt 4pt, linecolor=SlateGrey, nodesep=4pt, boxsize=0.25}
\ncbox{N1}{N2}
\ncbox{N3}{N4}
\end{postscript}
\end{table}
}

\lipsum[3-4]

    \end{document} 

enter image description here

7
  • I not see your image.
    – Sebastiano
    Commented Mar 2, 2017 at 11:19
  • @Sebastiano: ??? I can see it. A problem with your browser?
    – Bernard
    Commented Mar 2, 2017 at 11:38
  • Now I see your image. Before there was a small icon. I saw that a few times imgur.com does not work well. I vote often you answer.
    – Sebastiano
    Commented Mar 2, 2017 at 11:40
  • Yes, I have another answer for which the server fails to load the image.
    – Bernard
    Commented Mar 2, 2017 at 11:41
  • This is great! Almost exactly what I was going for. But somehow I seem to have trouble compiling your code? Any idea to why it wont work? I am using sharelatex as of now - but it wont work in TexMaker either. I get warnings regarding the auto-ost-pdf package
    – SJdtu
    Commented Mar 2, 2017 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .