如何更改 polynom 包中的字体大小?

如何更改 polynom 包中的字体大小?

使用 polynom 包执行多项式长除法时如何更改字体大小?例如,如何让它显示在 /scriptstyle 中?

下面是我目前拥有的图像,我将在图像下方附上代码。我怎样才能干净地重写它,但使用脚本字体?

非常感谢你的协助。

在此处输入图片描述

    \documentclass{standalone}
\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-5.7pt&}%
    \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+4x^2+x-1}{x^3+x^2}\]
\end{document}

答案1

您可以polynom在构建阶段为 定义一个新键并注入代码。请注意,加载amsmath是必不可少的(如果您使用标准字体;如果您加载lmodern,请确保也加载fixcmex)。

\documentclass{article}
\usepackage{amsmath}
\usepackage{polynom}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\pld@PrintLongDiv}
 {\begingroup}
 {\begingroup\pld@FONTSIZE}
 {}{}
\define@key{pld}{fontsize}{\def\pld@FONTSIZE{#1}}
\def\pld@FONTSIZE{}
\makeatother


\begin{document}

\[
\polylongdiv{x^3+4x^2+x-1}{x^3+x^2}
\]

\[
\polylongdiv[fontsize=\scriptsize]{x^3+4x^2+x-1}{x^3+x^2}
\]

\polylongdiv[fontsize=\LARGE]{x^3+4x^2+x-1}{x^3+x^2}

\end{document}

在此处输入图片描述

但是,根据您提出的括号修复方法,对齐并不总是精确的,还需要进行一些工作。

答案2

这是成品,再次感谢!

在此处输入图片描述

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{xpatch}
\usepackage{polynom}
\makeatletter
\xpatchcmd{\pld@PrintLongDiv}%%%%--> credit: egreg
 {\begingroup}
 {\begingroup\pld@FONTSIZE}
 {}{}
\define@key{pld}{fontsize}{\def\pld@FONTSIZE{#1}}
\def\pld@FONTSIZE{}%%%%

\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{\raisebox{3pt}{\big)}}\kern-3.4pt&}%
    \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[fontsize=\scriptsize]{x^3+4x^2+x-1}{x^3+x^2}
\end{document}

相关内容