# *noob* LaTeXiT long division

Like it says in the title I'm a complete noob trying to get LaTeXiT to do a simple long division sum.

Like it says I'm a complete noob I need someone to walk me through this step-by-step I'm not familiar with any of the code etc..

I'm already way behind on all my work.

Thanks Brett

Picture of what the output should look like:

• PS: I'd like to make it do the long division in an 'array' style I guess thats what its called? By that I mean I don't wanna have it solve the sum for me except I'd like to type out the sum myself in steps and export a pdf of each step. – Brett Jun 13 '17 at 13:03
• Instead of a rant, it would be better if you posted what you've already tried. Are you trying long division of integers, or polynomials? Do any of the "Related" links to the right help? But really, LaTeX is best at typesetting when you already have the material. But it is a programming language, so it can be forced to do whatever calculations you need, long division being one of them. – Teepeemm Jun 13 '17 at 13:11
• Can you maybe post a picture of what the output should look like? In the title you talk about division, in the question you talk about sum? What are you trying to do? – user36296 Jun 13 '17 at 13:12
• In answer to your implied question "Why is LaTeX considered so awesome by such a large group of people, but seems so difficult to use for a beginner?", I recommend checking out this post. Additionally, I think you will find that not only is LaTeX quite powerful and useful as you learn more about it, you will also find that it becomes easier over time. Plus, look at this great community willing to help you! – sk8forether Jun 13 '17 at 14:52
• I am downvoting, given the general tone of rudeness emanating from the angry OP, both here and in the comments to my answer. – Steven B. Segletes Jun 14 '17 at 11:12

What you are writing seems to be close to a tabular. Why don't you go for an easy approach:

\documentclass[pagesize, english]{scrartcl}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel, array, booktabs, ragged2e}

\begin{document}

\begin{tabular}{*{8}{>{\Centering}p{1cm}}}
& & & $+x^4$ & $+x^3$ & & & $+1$\\\midrule
$+x^7$ & $+x^6$ & $+x^5$ & & & $+x^2$ &$+x$ & \\
$+x^7$ &  & $+x^5$ & $+x^4$ & & $+x^2$ &$+x$ & \\\cmidrule{1-4}
\multicolumn{8}{l}{\dots}
\end{tabular}

\end{document}


And so on... Beware, I've no idea about mathematics! You'll get the manual of any package by texdoc packagenameon the command line.

It is not ideal, because tabstackengine does not have cell underlining/fill facilities built in. (see ADDENDUM for the beginnings of a remedy to that)

\documentclass{article}
\usepackage{tabstackengine,mathtools}
\stackMath
\setstacktabbedgap{1.5ex}
\setstackgap{S}{3pt}
\newcommand\showdiv[1]{\smash{\raisebox{1.5pt}{\scalebox{1.15}{)}}}#1}
\newcommand\laprule[1]{\rlap{\rshift\smash{\rule[-1pt]{#1}{.5pt}}}}
\makeatletter
\newcommand\rshift[1][0pt]{\hspace{\dimexpr#1+\tabbed@gap\relax}}
\makeatother
\begin{document}
$\tabbedShortstack[r]{ & & & & +x^4 & +x^3 & & & +1\\ \laprule{188pt}&&&&&&&&\\ x^3 + x + 1 & \showdiv{{+}x^7} & +x^6 & +x^5 &&&+x^2 & +x & \\ & +x^7 && +x^5 & +x^4&&&&\\ \laprule{97pt}&&&&&&&&\\ && +x^6 && +x^4 &&&&\\ && +x^6 && +x^4 & +x^3&&&\\ &\laprule{94pt}&&&&&&&\\ &&&&& +x^3 & +x^2 & +x&\\ &&&&& +x^3 && +x &+1\\ &&&&\laprule{84pt}&&&&\\ &&&&&& +x^2 & &+1 }$
\end{document}


I've been meaning, for a while, to create the TABstack equivalent of \hline and \cline. This will alleviate the need to estimate actual lengths for lapped underlines. This seemed like a good problem on which to start. I have, for the moment, built the underlying \TABrule which, at this time needs to be called in each field where it is used. Eventually, I hope to be able to build a \TABhline and \TABcline which will construct a string of \TABrule& combinations to make the syntax shorter. But here it is so far. If successful, I will implement into the tabstackengine package.

\documentclass{article}
\usepackage{tabstackengine,mathtools}
\stackMath
\setstacktabbedgap{1.5ex}
\setstackgap{S}{3pt}
\newcommand\showdiv{\llap{\smash{\raisebox{1.8pt}{\scalebox{1}[1.2]{)}}}}}
\newcommand\laprule[1]{\rlap{\rshift\smash{\rule[-1pt]{#1}{.5pt}}}}
\makeatletter
\newcommand\rshift[1][0pt]{\hspace{\dimexpr#1+\tabbed@gap\relax}}
\makeatother
%%%%%%%%%%%%%
\makeatletter
\def\trao{0pt}
\newcommand\TABrule[1][\trao]{%
\ifnum1=\value{TABcolindex@}\relax%
\makebox[\TABwd{\theTABcolindex@}][l]{%
\rule[\trao]{\dimexpr\TABwd{\theTABcolindex@}+.5\dimexpr\TAB@gap\relax}{\fboxrule}}%
\else%
\ifnum\TABcells{1}=\value{TABcolindex@}\relax%
\makebox[\TABwd{\theTABcolindex@}][r]{%
\rule[\trao]{\dimexpr\TABwd{\theTABcolindex@}+.5\dimexpr\TAB@gap\relax}{\fboxrule}}%
\else%
\makebox[\TABwd{\theTABcolindex@}][c]{%
\rule[\trao]{\dimexpr\TABwd{\theTABcolindex@}+1.\dimexpr\TAB@gap\relax}{\fboxrule}}%
\fi%
\fi%
}
\newcommand\set@TABrule@gap[1]{%
\ifstrequal{#1}{D}{\def\TAB@gap{\tabbed@gap}}{%
\ifstrequal{#1}{A}{\def\TAB@gap{0pt}}{\def\TAB@gap{\tabular@gap}}%
}%
}
\usepackage{xpatch}
\xpatchcmd{\@TAB@stack}{\bgroup}{\bgroup\set@TABrule@gap{#3}}{}{}
\xpatchcmd{\@TABstackonunder}{\bgroup}{\bgroup\set@TABrule@gap{#4}}{}{}
\makeatother
%%%%%%%%%%%%%
\begin{document}
$\tabbedShortstack[r]{ & & & & +x^4 & +x^3 & & & +1\\ &\TABrule&\TABrule&\TABrule&\TABrule&\TABrule&\TABrule&\TABrule&\TABrule\\ x^3 + x + 1 & \showdiv{+}x^7 & +x^6 & +x^5 &&&+x^2 & +x & \\ & +x^7 && +x^5 & +x^4&&&&\\ &\TABrule&\TABrule&\TABrule&\TABrule&&&&\\ && +x^6 && +x^4 &&&&\\ && +x^6 && +x^4 & +x^3&&&\\ &&\TABrule&\TABrule&\TABrule&\TABrule&&&\\ &&&&& +x^3 & +x^2 & +x&\\ &&&&& +x^3 && +x &+1\\ &&&&&\TABrule&\TABrule&\TABrule&\TABrule\\ &&&&&& +x^2 & &+1 }$
\end{document}


• Hi I'm not using terminal I'm using Latexit. When I copy the code you'd posted into Latexit it just gives me a bunch of errors. It says misplaced alignment tab character & a bunch of times as well as undefined controls sequence. – Brett Jun 13 '17 at 16:20
• Perhaps you guys could give me a simple code and we could see if this stupid thing does anything useful at all? Maybe go from there? – Brett Jun 13 '17 at 16:31
• @Brett Since you are using LaTeXiT, which claims to allow you to write LaTeX "without bothering with file creation, preambles, and so on", you have to edit the preferences as suggested in this post to get the correct setup to match these suggested answers. Alternatively, you could use ShareLaTeX, Overleaf, or install another editor. – sk8forether Jun 13 '17 at 19:10
• @Brett While I understand how frustrating not understanding something can be, that does not make it useless. An unwillingness to learn will always make something harder, and take longer. Therefore, please take the time to be patient and kind to us also as we help you. As for ShareLaTeX, simply click on Register to create a free account. On the welcome page, you will find links to their templates and LaTeX Documentation, which would be a good place for you to start. – sk8forether Jun 14 '17 at 15:44
• @Brett Once you have started your first empty project, I think you will find that copying and pasting Steven B. Segletes' answer does what you have requested quite well. If so, at that point it would be appropriate to accept it. – sk8forether Jun 14 '17 at 15:50