# Using vertical line column separator in tabular between JUST TWO cells

I'm trying to do long division using tabular environment. Here is the code:

\documentclass[11pt]{book}
\usepackage{multirow}
\begin{document}
\begin{center}
\begin{tabular}{c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{}}
\multirow{2}{*}{$-$}&1&5&7&{\huge,}&5&&&5&{\color{white}1}&{\color{white}1}&    {\color{white}1}\\
\cline{9-12}
&1&5&&&&{\color{white}1}&{\color{white}1}&3&1&&\\
\cline{2-6}
\multirow{2}{*}{$-$}&&&7&&&&&&&&\\
&&&5&&&&&&&&\\
\cline{2-6}
&&&2&&&&&&&&\\
\end{tabular}
\end{center}
\end{document}


I'm trying to achieve long division layout which is used in my country. It is very similar to the one used in France with the exception of the vertical line that exists only in the first row and does not go all the way down.

To achieve this, I create my table without any vertical separators between the columns and want to add it only in the first row, before the number "5".

The code above yields the second picture. Is it possible to somehow insert that single vertical line?

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Andrew Swann Oct 12 '13 at 18:54

For example

\documentclass[11pt]{book}
\usepackage{color}
\usepackage{multirow}
\begin{document}
\begin{center}
\begin{tabular}{c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{} c@{}}
%\multirow{2}{*}{$-$}&1&5&7&{\huge,}&5&&&5&{\color{white}1}&{\color{white}1}&    {\color{white}1}\\
\multirow{2}{*}{$-$}&1&5&7&{\huge,}&5&&&\vline\,5&{\color{white}1}&{\color{white}1}&    {\color{white}1}\\
\cline{9-12}
&1&5&&&&{\color{white}1}&{\color{white}1}&3&1&&\\
\cline{2-6}
\multirow{2}{*}{$-$}&&&7&&&&&&&&\\
&&&5&&&&&&&&\\
\cline{2-6}
&&&2&&&&&&&&\\
\end{tabular}
\end{center}
\end{document}


• Thanks, that's what I wanted - it works very well and is clean and simple :) – Rokas Oct 12 '13 at 20:29
• @Rokas Notice that you can replace all occurrences of {\color{white}1} with \hphantom{1} (there's no need to print white characters). – karlkoeller Oct 13 '13 at 5:25

Here's an approach that doesn't use tabular but instead stacking. \vst is the vertical strut you sought, while \bvst is a blank placeholder that takes the identical horizontal space. \pul is the underlining mechanism and \hc is your huge comma.

\documentclass[11pt]{book}
\usepackage{stackengine}
\begin{document}
{\centering
\def\hc{{\Huge,}}
\def\pul{\protect\underline}
\def\vst{\protect\smash{\rule[-1.8pt]{.1ex}{2.5ex}\protect\rule{.4ex}{0ex}}}
\def\bvst{\protect\rule{.5ex}{0ex}}
\Longunderstack[l]{\pul{~~}157\hc5 ~~\pul{15~~~~~} %
\underline{~~}~~~7 %
~~\underline{~~~5~~~~} ~~~~~2}
\Longunderstack[l]{\underline{\vst5~~~~} \bvst31}\par}
\end{document}


With the next release of stackengine in a few days, you won't need to \protect the arguments to \Longunderstack, thanks to help from egreg.

This doesn't answer your question but... why don't you take a look at the xlop package?

Example

\documentclass[11pt]{book}
\usepackage{xlop}

\begin{document}

\opdiv[shiftdecimalsep=none,displayintermediary=nonzero]{157.5}{5}

\end{document}


Output

• I was just writing exactly the same answer :) but seem that the OP ask for a "vertical line that exists only in the first row". – Fran Oct 12 '13 at 19:26
• @Fran In fact I stated that this doesn't answer the question. But sometimes it is better to change one's approach to a problem :) – karlkoeller Oct 12 '13 at 19:29
• Thanks for the suggestion. I have actually looked into the xlop package and decided against using it. The thing is, while xlop does its stuff nicely, I need more control over the tiny bits here and there. And that vertical bar is one thing I really need to get rid of. – Rokas Oct 12 '13 at 19:32
• @Rokas OK, this was only a suggestion :-) – karlkoeller Oct 12 '13 at 19:33
• @karlkoller. Of course, It's what I would have done if you had not answered before. Point to the downside was only a little revenge because the overtaking (but don't have in mid, before I upvoted you too) :) – Fran Oct 12 '13 at 21:22