1

I'm making tables for displaying the method to represent how factorial polynomials are derived by using a tabular method:

tabular method

As can be seen here, the table has partially ruled vertical lines, trying to replicate this for my assignment using \vrule has given me some issues:

my attempt to replicate

As can be seen, the \vrule do not align, any help is greatly appreciated

MWE

\begin{tabular}{cc|cc|ccc}
   1& &2& &6& &\vrule-8\\
   & & & &2& &\vrule\\
 \cline{3-6}
   2& &2& &8& &\\
 \cline{3-4}
\end{tabular}

Note: apologies for atrocious formatting, I wrote this on my phone in a hurry.

  • The |-8 and | are treated as part of the column (which is centered). A left justified column would work better. Typically one uses \multicolumn to turn vertical lines on and off. See tex.stackexchange.com/questions/257073/… – John Kormylo Feb 3 '17 at 4:39
  • BTW, $-8$ will use a real minus sign as in the equation. - in text mode is just a small hyphen, not a minus sign. – Heiko Oberdiek Feb 3 '17 at 6:28
  • @HeikoOberdiek Yeah, I realised I missed that after I posted it – Xylius Feb 3 '17 at 6:29
4

Example that uses array for math mode in the cells (minus sign, digits), vertical tabular lines, which can be overwritten by \multicolumn, and \cline:

\documentclass{article}

\begin{document}
$\begin{array}{r|r|r|r}
  1 & 2 & 6 & -8 \\
  & & 2 & \\
  \cline{2-3}
  2 & 2 & \multicolumn{1}{r}{8} \\
  & \\
  \cline{2-2}
\end{array}$
\end{document}

Result

Also package siunitx can be used to properly align the numbers, but adding some space to the right by place for phantom digits. (The reason for the additional space to the right eludes me.)

\documentclass{article}
\usepackage{siunitx}

\begin{document}
$\sisetup{table-format=1.1}
\begin{array}{S|S|S|S[table-format=-1]}
  1 & 2 & 6 & -8 \\
  & & 2 & \\
  \cline{2-3}
  2 & 2 & \multicolumn{1}{S}{8} \\
  & \\
  \cline{2-2}
\end{array}$
\end{document}

Result

  • Thanks very much for you answer, I didn't know you could implement multicoloumns into arrays. Is there by any chance that i can add an extra column to have the gap between numbers and column lines (just out of preference) like in my example?. – Xylius Feb 3 '17 at 6:45
  • I played around with the columns and i don't seem to be yeilding any results – Xylius Feb 3 '17 at 6:45
  • \begin{document} $\sisetup{table-format=1.1} \begin{array}{*{3}{S[table-format=1]|}S[table-format=-1]} 1 & 2 & 6 & -8 \\ & & 2 & \\ \cline{2-3} 2 & 2 & \multicolumn{1}{S[table-format=1]}{8} \\ & \\ \cline{2-2} \end{array}$ \end{document} solve problem of additional space :-) – Zarko Feb 3 '17 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.