GeneralChanging the brace »)« to a pipe »|« in polynom package

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Changing the brace »)« to a pipe »|« in polynom package

Post by yoyoimut »

Hi everyone,

I am useing polynom package to write my mathematics book.
However, I am not so happy with the rendered output of long division as shown below.

Polynom.sty : http://www.ctan.org/tex-archive/macros/ ... ib/polynom

Not so beautiful
bad.jpg
bad.jpg (24.63 KiB) Viewed 2639 times
I want to change it as follows.

Beautiful
good.jpg
good.jpg (18.79 KiB) Viewed 2639 times
If we can change the package, how to do it?

Thank you in advance.


regards,

Yuko
Last edited by yoyoimut on Tue Feb 16, 2010 2:03 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing the brace »)« to a pipe »|« in polynom package

Post by localghost »

Please upload attachments to the forum server (done here subsequently). External links can get lost with time and make a problem incomprehensible.
yoyoimut wrote:[...] Polynom.sty : http://www.cs.brown.edu/system/software ... olynom.pdf [...]
I wonder where people always get those links from. Just link to CTAN.

Code: Select all

http://ctan.org/pkg/polynom
There you will always get the current version of a package as well as its manual. Other links may contain obsolete versions.
yoyoimut wrote:[...] If we can change the package, how to do it? [...]
It is not recommendable to modify a package directly. Necessary modifications are done better by taking the critical part of the package code and modify it in the preamble of the document. This has been done in the code below.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{polynom}

\makeatletter
\def\pld@ArrangeResult#1{%
    \ifx\pld@remainder\@empty
        \@tempcnta\pld@maxcol\relax
        \pld@InsertItems@do\pld@lastline
            {\pld@firsttrue\pld@PLD{\pld@R{0}{1}}}%
    \fi
    \ifnum\pld@currstage>\z@
        \pld@Extend\pld@allines{\pld@lastline\cr}%
    \else
        \pld@InsertFake\pld@lastline
    \fi
    \pld@iftopresult
        \def\pld@lastline{\pld@PrintPoly\pld@divisor\,\smash{\Big|}\kern-2pt&}%
    \else
        \let\pld@lastline\@empty
        \ifx B\pld@style\else
            \def\pld@lastline{\pld@leftdelim\strut\pld@rightxdelim&}%
        \fi
    \fi
    \expandafter\pld@AR@col\expandafter\pld@PLD
                           \expandafter\pld@lastline#1+\relax+%
    \pld@SplitQuotient
    \pld@iftopresult
        \let\pld@currentline\@empty
        \expandafter\pld@AR@col\expandafter\pld@PLD
                               \expandafter\pld@currentline
                                           \pld@quotient+\relax+%
        \expandafter\pld@AR@col\expandafter\pld@XPLD
                               \expandafter\pld@currentline
                                           \pld@shadow+\relax+%
        \edef\pld@subline{%
            \noexpand\cline{\tw@-\pld@maxcol}%
            \noalign{\vskip\jot}}%
        \pld@Extend\pld@currentline{\expandafter\cr\pld@subline}%
    \else
        \@tempcnta-\@tempcnta
        \advance\@tempcnta\pld@maxcol\relax \advance\@tempcnta\@ne
        \edef\pld@span{\the\@tempcnta}%
        \ifx B\pld@style
          \pld@AddTo\pld@lastline{%
            &\multispan\pld@span${}=%
            \pld@PrintPolyWithDelims\pld@divisor
            \expandafter\pld@IfSum\expandafter{\pld@divisor}{}{\cdot}%
            \expandafter\pld@IfSum\expandafter{\pld@quotient}\pld@true
                                                             \pld@false
            \pld@if \pld@leftdelim
                    \pld@PrintPolyShadow
                    \pld@rightdelim
              \else \pld@PrintPolyShadow \fi
            \pld@firstfalse
            \expandafter\pld@PrintRemain\expandafter{\pld@remainder}$}%
        \else
          \pld@AddTo\pld@lastline{%
            &\multispan\pld@span$\pld@leftxdelim\strut\pld@rightdelim
            \pld@div
            \pld@PrintPolyWithDelims\pld@divisor=
            \pld@PrintPolyShadow
            \ifx\pld@remainder\@empty\else
                +{}%
                \setbox\z@=\hbox{$\displaystyle
                  \frac{\let\strut\@empty\pld@firsttrue \expandafter
                        \pld@PrintRemain\expandafter{\pld@remainder}}%
                       {\let\strut\@empty\pld@PrintPoly\pld@divisor}$}%
                \dp\z@=\z@\box\z@
            \fi
            $}%
        \fi
    \fi
    \expandafter\pld@AR@\pld@allines\relax}
\makeatother

\begin{document}
  \polylongdiv{x^3+x^2-1}{x-1}
\end{document}

Best regards
Thorsten
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Re: Changing the brace »)« to a pipe »|« in polynom package

Post by yoyoimut »

Dear localghost,

I just noticed your additional post.

That is really helpfull and works the way I want. :o

Thank you very much.


regards,


Yuko.
Post Reply