tkz-tab 及其 PSTricks 包等效项存在问题

tkz-tab 及其 PSTricks 包等效项存在问题

我的代码:(使用 tkz-tab)

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb,newcent}
\usepackage{tkz-tab}
\begin{document}
\begin{tikzpicture}
\tkzTabInit{$x$ /1, $g'(x)$ /1, $g(x)$ /3.5} 
{$-\infty$,$a$,$1$,$3$, $+\infty$}
\tkzTabLine{,-,0,+,0,-,0,+  }
\tkzTabVar{+/$+\infty$, -/$m-\dfrac{1}{4}$ , +/$g(1)$, -/$m$, +/$+\infty$}
\end{tikzpicture}
\end{document}

编译结果:

在此处输入图片描述

问题:

  1. 如何m-1/4低于m?这意味着

在此处输入图片描述 2. PSTricks 是否有与以下相同的命令或包(我不知道)tkz-tab? 假设没有任何命令或包,那么如何仅使用环境来创建它pspicture

答案1

对于你的第一个问题,这是你想要的吗?注意,我用 $\mfrac{1}{4}$( 的中等大小分数)替换了 $\dfrac{1}{4}$ ,因为我认为用作数值系数看起来更好。 和nccmath的水平对齐是通过在后者上添加 a 获得的,因此包含两个最小值的框具有相同的高度。m-\mfrac{1}{4}m\vphantom{\mfrac{1}{4}}

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath, amssymb, newcent}
\usepackage{tkz-tab}
\usepackage{nccmath}

\begin{document}

\begin{tikzpicture}
\tkzTabInit{$x$ /1, $g'(x)$ /1, $g(x)$ /3.5}
{$-\infty$,$a$,$1$,$3$, $+\infty$}
\tkzTabLine{,-,0,+,0,-,0,+ }
\tkzTabVar{+/$+\infty$, -/$m-\mfrac{1}{4}$ , +/$g(1)$, -/$m\vphantom{\mfrac 14}$, +/$+\infty$}
\end{tikzpicture}

\end{document} 

在此处输入图片描述

编辑:看来我误解了要求。我希望以下代码更符合你的要求(相同的序言):

\begin{tikzpicture}
\tkzTabInit{$x$ /1, $g'(x)$ /1, $g(x)$ /3.5}
{$-\infty$,$a$,$1$,$3$, $+\infty$}
\tkzTabLine{,-,0,+,0,-,0,+ }
\tkzTabVar{+/$+\infty$, -/$m-\mfrac{1}{4}$ , +/$g(1)$, -/\raisebox{4ex}{$m\vphantom{\mfrac{1}4}$}, +/$+\infty$}
\end{tikzpicture}

在此处输入图片描述

答案2

您可以使用新的tablvar包(法语文档):

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[tikz]{tablvar}

\begin{document}

\[
\begin{tablvar}{4}
\hline
x & -\infty && a && 1 && 3 && +\infty \\
\hline
g'(x) && - & 0 & + & 0 & - & 0 & + & \\
\hline
\variations{
  \mil{g(x)} &
  \haut{+\infty} &&
  \bas{m-\dfrac{1}{4\mathstrut}} &&
  \haut{g(1)} &&
  \bas{m} &&
  \haut{+\infty}
}
\hline
\end{tablvar}
\]

\end{document}

删除该tikz选项会使该包依赖于 PSTricks。

在此处输入图片描述

如果你想轻松移动向上(我看不出这有必要),提高它。

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[tikz]{tablvar}

\begin{document}

\[
\begin{tablvar}{4}
\hline
x & -\infty && a && 1 && 3 && +\infty \\
\hline
g'(x) && - & 0 & + & 0 & - & 0 & + & \\
\hline
\variations{
  \mil{g(x)} &
  \haut{+\infty} &&
  \bas{m-\dfrac{1}{4\mathstrut}} &&
  \haut{g(1)} &&
  \bas{\raisebox{2ex}{$m\mathstrut$}} &&
  \haut{+\infty}
}
\hline
\end{tablvar}
\]

\end{document}

在此处输入图片描述

答案3

题外话!对于具有最小一个有理零点的多项式和有理函数,我们可以借助 xintexpr 和 polexpr 包进行因式分解并找到(唯一)有理根。然后表格会自动生成。

因此我们可以在文档中输入例如

\poldef zf1(x):=(-1/4)(x^2-4x+3)(x-2)^2(x^2+1)(x^2+2);
\PolReduceCoeffs{zf1}
Given is the derivative:
\[f^{\prime}:t \mapsto \PolTypeset[t]{zf1} = \typesetFactors[t]{zf1} \]

\medskip
\renewcommand{\arraystretch}{1.2}%
\VZTabelle[f][t][zf1]

这是完整示例的代码。

\documentclass[fleqn,svgnames,x11names,dvipsnames]{article}

\usepackage[a4paper,margin=1.25cm]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{xintexpr}
\usepackage{polexpr}
\usepackage{xfp,xparse,expl3,xstring}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{group-separator={\,},output-decimal-marker={,},exponent-product=\cdot,per-mode=fraction,product-units=single,
input-product=*,output-product=\cdot,unit-mode=text,quotient-mode=fraction,locale=DE,range-phrase = { bis }}
\usepackage{pstricks}

\let\funk\PolToExpr
\let\STZeroL\PolSturmIsolatedZeroLeft

\NewExpandableDocumentCommand{\XcalcR}{sO{8}m}{%  calculates #3 and rounds to #2 decimals; non formating: for formated output use \Xcalc not \XcalcR
\PolDecToString{\xintREZ{\xinttheiexpr[#2]reduce(#3)\relax}}%
}

\NewDocumentCommand{\Xcalc}{t+stDsO{2}m}{% calculates #5, rounds to #4 decimals (trailing zeros are supressed) and typesets the number with num-macro formatting
\IfBooleanT{#1}{\xintifSgn{\xinttheexpr #6\relax}{}{+}{+}}%  or as fraction, reduced or not reduced and with #3=D is a boolean in displaystyle
\IfBooleanTF{#2}%
  {\IfBooleanT{#3}{\displaystyle}%
    \IfBooleanTF{#4}%
        {\xintSignedFrac{\xinttheexpr #6\relax}}%
        {\xintSignedFrac{\xinttheexpr reduce(#6)\relax}}%
    }%
    {\num{\PolDecToString{\xintREZ{\xinttheiexpr[#5]reduce(#6)\relax}}}}%
}


\newcommand{\NullStellen}[1]{%
   \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#1}}}
   \do
   {x_{##1} = \Xcalc{\PolSturmIsolatedZeroLeft{#1}{##1}}%
   \xintifForLast{}{; }}%
}


\NewDocumentCommand{\hackNst}{O{nt}D(){x}m}{%
    \xintifboolexpr{\PolSturmNbOfIsolatedZeros{#3}=0}{}{%
    \xintiloop [1+1]
    \expandafter\def\expandafter\tmp\xintbracediloopindex
    \xintdefvar #2\tmp = \PolSturmIsolatedZeroLeft{#3}\tmp;
    \xintdefvar #1\tmp = \PolSturmIsolatedZeroMultiplicity{#3}\tmp;
    \ifnum\xintiloopindex<\numexpr\PolSturmNbOfIsolatedZeros{#3}\relax
    \repeat
    }%
}

\NewDocumentCommand{\GenFloatSturmZeros}{ssO{9}D(){x}m}{%
\IfBooleanTF{#1}%
    {%
    \PolToSturm{#5}{#5}%
    \PolSturmIsolateZeros**{#5}%
    \PolEnsureIntervalLengths{#5}{-#3}%
    \IfBooleanF{#2}{\hackNst(#4){#5}}%
    }%
    {%
    \PolGenFloatVariant{#5}%
    \PolToSturm{#5}{#5}%
    \PolSturmIsolateZeros**{#5}%
    \PolEnsureIntervalLengths{#5}{-#3}%
    }%
}


\def\smstext{steigt}%
\def\smftext{fällt}
\def\HPtext{Hochpkt.}
\def\TPtext{Tiefpkt.}
\def\SPtext{Terrassenpkt.}
\def\DiffRowtxt{f^{\prime}}
\def\lueckColor#1{\colorlet{lckColor}{#1}}
\lueckColor{BrickRed}
\def\Poltxt{\textcolor{lckColor}{Polstelle}}
\def\Lueckentxt{\textcolor{lckColor}{Def.-Lücke}}
\def\Notdeftxt{\textcolor{lckColor}{\diagup}}

\NewDocumentCommand{\VZTabelle}{sO{f}O{x}O{#21}!d()}{%
\IfValueTF{#5}{%
                \PolGCD{#4}{#5}{commonfactorA}%
                \poldef erwzaehlerA(x) := (#4(x)#5(x))/(commonfactorA(x))^2 ;%
                \poldef gekuerzterNenner(x) := #5(x)/commonfactorA(x) ;%
                \PolGCD{erwzaehlerA}{commonfactorA}{commonfactorB}%
                \poldef commonfactorC(x) := commonfactorA(x)/commonfactorB(x) ;%
                \poldef erwzaehler(x) := erwzaehlerA(x)commonfactorC(x) ;%
              }%
              {%
                \poldef erwzaehler(x) := #4(x) ;%
                \poldef commonfactorC(x) := 1 ;%
              }%
    \PolToSturm{erwzaehler}{erwzaehler}%
    \PolSturmIsolateZeros**{erwzaehler}%
    \PolEnsureIntervalLengths{erwzaehler}{-9}%
\begin{tabular}{*{\XcalcR{2+2*\PolSturmNbOfIsolatedZeros{erwzaehler}}}{>{$}c<{$}}}
 \IfBooleanF{#1}{\toprule}
    \IfValueTF{#5}{\Firstrow{erwzaehler}{#3}{#5}}{\Firstrow{erwzaehler}{#3}{1}}
    \IfValueTF{#5}{\VZmakerows{erwzaehler}{#5}{#4}{#3}}{\VZmakerows{erwzaehler}{1}{#4}{#3}}
    \IfValueTF{#5}{\Diffrow{\DiffRowtxt}{erwzaehler}{#3}{#5}}{\Diffrow{\DiffRowtxt}{erwzaehler}{#3}{1}}
    \IfValueTF{#5}{\Graphrow{#2}{erwzaehler}{#5}}{\Graphrow{#2}{erwzaehler}{1}}
 \IfBooleanF{#1}{ \\ \bottomrule}
\end{tabular}%
}

\def\leadcoef#1{\xintifboolexpr{\PolLeadingCoeff{#1}=1}{}{\Xcalc{\PolLeadingCoeff{#1}}\cdot}}

\def\nst#1#2{\Xcalc*{\STZeroL{#1}{#2}}}

\def\VZfktwertL#1#2{\xintifSgn{\xinttheexpr #1(\xinttheexpr \STZeroL{#1}{#2}-0.001\relax)\relax}{-}{0}{+}}

\def\VZfktwertR#1#2{\xintifSgn{\xinttheexpr #1(\xinttheexpr \STZeroL{#1}{#2}+0.001\relax)\relax}{-}{0}{+}}

\def\VZfktwert#1#2{\xintifSgn{\xinttheexpr #1(\STZeroL{#1}{#2})\relax}{-}{0}{+}}

\def\tabfactor#1#2#3#4{%
        \xintifboolexpr{\STZeroL{#1}{#2}=0}%
                {#4}%
                {(#4\Xcalc+*{-\STZeroL{#1}{#2}})
                  \xintifboolexpr{\PolSturmIsolatedZeroMultiplicity{#1}{#2}=1}%
                    {%
                        \xintifboolexpr{commonfactorC(\STZeroL{#1}{#2})=0}%
                            {^{0}}%
                            {}%
                    }%
                    {%
                        \xintifboolexpr{commonfactorC(\STZeroL{#1}{#2})=0}%
                                            {%
                                                ^{0}
                                            }%
                                            {%
                                                ^{\PolSturmIsolatedZeroMultiplicity{#1}{#2}}
                                            }%
                    }%
                }%
}


\def\MonotonieL#1#2{\xintifSgn{\xinttheexpr #1(\XcalcR{\STZeroL{#1}{#2}-0.001})\relax}{\text{\smftext}}{0}{\text{\smstext}}}

\def\MonotonieR#1#2{\xintifSgn{\xinttheexpr #1(\XcalcR{\STZeroL{#1}{#2}+0.001})\relax}{\text{\smftext}}{0}{\text{\smstext}}}

\def\Extrema#1#2{\xintifboolexpr{\xinttheexpr (#1(\XcalcR{\STZeroL{#1}{#2}-0.001}))*(#1(\XcalcR{\STZeroL{#1}{#2}+0.001}))\relax >0}%
        {\text{\SPtext}}%
        {%
          \xintifboolexpr{\xinttheexpr #1(\xinttheexpr \STZeroL{#1}{#2}-0.001\relax)\relax>0}%
                {\text{\HPtext}}%
                {\text{\TPtext}}%
        }%
   }%


\NewDocumentCommand{\VZtabfac}{st{>}mmm}{%
\IfBooleanTF{#1}%
    {\xintifSgn{\xinttheexpr (-\STZeroL{#3}{#4}+\STZeroL{#3}{#5})^\xintifboolexpr{commonfactorC(\STZeroL{#3}{#4})=0}{0}%
    {\PolSturmIsolatedZeroMultiplicity{#3}{#4}}\relax}{-}{0}{+}}%
    {%
      \IfBooleanTF{#2}%
        {%
            \xintifSgn{\xinttheexpr (-\STZeroL{#3}{#4}+\STZeroL{#3}{#5}+0.001)^\xintifboolexpr{commonfactorC(\STZeroL{#3}{#4})=0}{0}%
            {\PolSturmIsolatedZeroMultiplicity{#3}{#4}}\relax}{-}{0}{+}%
        }%
        {%
            \xintifSgn{\xinttheexpr (-\STZeroL{#3}{#4}+\STZeroL{#3}{#5}-0.001)^\xintifboolexpr{commonfactorC(\STZeroL{#3}{#4})=0}{0}%
            {\PolSturmIsolatedZeroMultiplicity{#3}{#4}}\relax}{-}{0}{+}%
        }%
    }%
}


\newcommand{\VZmakerows}[4]{%
     \xintifboolexpr{\PolLeadingCoeff{#1}<0}%
                {%
                    \xintSignedFrac{\xintIrr{\PolLeadingCoeff{#1}}} & -
                    \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#1}}}
                        \do {  & - & - } \\ \midrule
                }%
                {}%
    \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#1}}}
    \do
        {\tabfactor{#1}{##1}{#3}{#4} & \VZtabfac{#1}{##1}{1}%
            \xintFor* ##2 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#1}}}
                \do
                {  &
                    \IfDecimal{#2}%
                       {\VZtabfac*{#1}{##1}{##2}}%
                       {%
                        \xintifboolexpr{\xinttheexpr #2(\STZeroL{#1}{##2})\relax = 0}%
                            {\Notdeftxt}
                            {\VZtabfac*{#1}{##1}{##2}}%
                        }%
                    &   \VZtabfac>{#1}{##1}{##2}
                }
     \\ \midrule
     }
}


\newcommand{\Firstrow}[3]{%
    #2 & -\infty<#2<\nst{#1}{1} & \IfDecimal{#3}{#2=\nst{#1}{1}}%
            {\xintifboolexpr{\xinttheexpr #3(\STZeroL{#1}{1})\relax = 0 }%
                    {\textcolor{lckColor}{#2=\nst{#1}{1}}}%
                    {#2=\nst{#1}{1}}%
            }%
\xintifboolexpr{\PolSturmNbOfIsolatedZeros{#1}>1}{%
   \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#1}-1}}
   \do
   {%
        & \nst{#1}{\xinttheexpr ##1\relax}<#2<\nst{#1}{\xinttheexpr ##1+1\relax} &
            \IfDecimal{#3}%
                {#2=\nst{#1}{\xinttheexpr ##1+1\relax}}%
                {\xintifboolexpr{\xinttheexpr #3(\STZeroL{#1}{\xinttheexpr ##1+1\relax})\relax = 0 }%
                    {\textcolor{lckColor}{#2=\nst{#1}{\xinttheexpr ##1+1\relax}}}%
                    {#2=\nst{#1}{\xinttheexpr ##1+1\relax}}%
                }%
   }%
   }%
   {}%
    & \nst{#1}{\PolSturmNbOfIsolatedZeros{#1}}<#2<+\infty\\ \midrule
}


\NewDocumentCommand{\Diffrow}{mmmm}{%
    #1(#3)
   \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#2}}}
   \do
   {& \VZfktwertL{#2}{##1} &
        \IfDecimal{#4}%
            {\VZfktwert{#2}{##1}}%
            {%
                \xintifboolexpr{\xinttheexpr #4(\STZeroL{#2}{##1})\relax = 0}%
                {\Notdeftxt}
                {\VZfktwert{#2}{##1}}%
            }%
   }%
    & \VZfktwertR{#2}{\PolSturmNbOfIsolatedZeros{#2}} \\ \midrule
}


\newcommand{\Graphrow}[3]{%
    \text{G}_{#1}
   \xintFor* ##1 in {\xintSeq{1}{\PolSturmNbOfIsolatedZeros{#2}}}
   \do
   {& \MonotonieL{#2}{##1} & \IfDecimal{#3}{\Extrema{#2}{##1}}{%
        \xintifboolexpr{\xinttheexpr #3(\STZeroL{#2}{##1})\relax = 0}%
            {%
                    \xintifboolexpr{\xinttheexpr gekuerzterNenner(\STZeroL{#2}{##1})\relax =0}%
                        {\text{\Poltxt}}
                        {\text{\Lueckentxt}}
            }%
            {\Extrema{#2}{##1}}%
        }%
   }%
    & \MonotonieR{#2}{\PolSturmNbOfIsolatedZeros{#2}}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin of code for factorization %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Counter for LOOP over the roots of f
\newcount\zeroCount
% Set counter to 1
\zeroCount=1

% Proof if a root is "0" then only write x and not (x-0) ...
% factor the roots like (x-x_1) if x_1>0, (x+x_1) if x_1<0
\newcommand{\factorZeros}[1]{%
    \xintifZero{\PolSturmIsolatedZeroLeft{#1}{\the\zeroCount}}%
        {\varname}
        {\left(\varname\xintiiifSgn{\PolSturmIsolatedZeroLeft{#1}{\the\zeroCount}}{+}{-}{-}
        \xintSignedFrac{\xintIrr{\xintAbs{\PolSturmIsolatedZeroLeft{#1}{\the\zeroCount}}}}\right)
        }
}

% Don't write multiplicity of a root in case it is =1
\newcommand{\ignoreMultiplicityOne}[1]{%
    \xintifOne{\PolSturmIsolatedZeroMultiplicity{#1}{\the\zeroCount}}{}{\PolSturmIsolatedZeroMultiplicity{#1}{\the\zeroCount}}
}

% Hide leading coefficient if leading coefficient is + or - 1.
\newcommand{\hideLeadingCoeff}[1]{%
\xintifOne{\xintAbs{\PolLeadingCoeff{#1}}}%
    {\xintiiifSgn{\PolLeadingCoeff{#1}}{-}{}{}}
    {\xintSignedFrac{\xintIrr{\PolLeadingCoeff{#1}}}}
}

% Typeset polynomial as factors of its rational roots: f(x)=a_n(x-x_1)(x-x_2)...(x-x_n)(quotient function)
\newcommand{\typesetFactors}[2][x]{%
\def\varname{#1}%
% #1 = function
\PolToSturm{#2}{#2}%
\PolSturmIsolateZeros**{#2}%
\xintifboolexpr{\PolDegree{#2}<2}{\xintifboolexpr{\PolDegree{#2}<1}{\PolTypeset[\varname]{#2}}{\left(\PolTypeset[\varname]{#2}\right)}}{%
\xintifboolexpr{\PolDegree{#2}=\PolDegree{#2_norr}}{\PolTypeset[\varname]{#2}}{%
\poldef #2_rat(x) := #2(x)/#2_norr(x);
\poldef #2_norr_VZ(x) := \xintSgn{\PolLeadingCoeff{#2_norr}}#2_norr(x);
\PolToSturm{#2_rat}{#2_rat}%
\PolSturmIsolateZeros**{#2_rat}%
%
\hideLeadingCoeff{#2}%
% Loop over all rational zeros of the function f = #2 ;  #2_rat is the part with only rational zeros
% #2_rat is defined as #2(x)/#2_norr(x), and #2_norr is the part of #2 with no rational roots (square-free version is #2_irr )
    \loop
        \factorZeros{#2_rat}^{\ignoreMultiplicityOne{#2_rat}}%
        \advance \zeroCount 1
        \ifnum \zeroCount<\xinttheexpr\PolSturmNbOfIsolatedZeros{#2_rat}+1\relax
    \repeat
\xintifZero{\PolDegree{#2_norr}}%
{}%
{\left(\PolTypeset[\varname]{#2_norr_VZ}\right)}%
}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of code for factorization %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\smstext{$\nearrow$}
\def\smftext{$\searrow$}
\def\HPtext{H}
\def\TPtext{T}
\def\SPtext{Ter.}
\def\DiffRowtxt{f^{\prime}}
\def\Poltxt{\textcolor{lckColor}{Pol}}
\def\Lueckentxt{\textcolor{lckColor}{Loch}}


\begin{document}

\poldef zf1(x):=(-1/4)(x^2-4x+3)(x-2)^2(x^2+1)(x^2+2);
\PolReduceCoeffs{zf1}
Given is the derivative:
\[f^{\prime}:t \mapsto \PolTypeset[t]{zf1} = \typesetFactors[t]{zf1} \]

\medskip
\renewcommand{\arraystretch}{1.2}%
\VZTabelle[f][t][zf1]
\bigskip

\poldef zf1(x):=(x^2-4x+3)*(x-2);
\PolReduceCoeffs{zf1}
\poldef nf1(x):=(x^2+1)(x-2)^2;
\PolReduceCoeffs{nf1}
Given is the derivative:
\[f^{\prime}:x \mapsto \frac{\PolTypeset{zf1}}{\PolTypeset{nf1}} = \frac{\typesetFactors{zf1}}{\typesetFactors{nf1}}\]

\medskip
\renewcommand{\arraystretch}{1.2}%
\VZTabelle[f][x][zf1](nf1)

\end{document}

在此处输入图片描述

相关内容