将分子和分母排版为与节点中其他字符相同的字体

将分子和分母排版为与节点中其他字符相同的字体

在显示屏上,我a想要2

\begin{equation*}
y=-\frac{a}{2}x^{2}
\end{equation*}

排版于font=\footnotesize

\documentclass{amsart}
\usepackage{mathtools,systeme,array}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=3in,grid=both,grid style={line width=.1pt, draw=gray!10},clip=false,
    axis lines=middle,
    xmin=-3,xmax=3,
    ymin=-5.5,ymax=10.5,
    restrict y to domain=-5.5:10.5,
    xtick={-3,-2,...,3},ytick={},
    ticklabel style={font=\tiny,fill=white},
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    axis line style={shorten >=-7.5pt, shorten <=-7.5pt},
    xlabel=$x$,
    ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west},
    axis on top
]

\addplot[samples=501,domain=-sqrt(5):sqrt(5),blue] {2*x^2}
node[anchor=north east,pos=0.25,xshift=-1pt,yshift=-1pt, circle, inner sep=1pt, fill=white, font=\footnotesize]{$y=ax^{2}$};

\addplot[samples=501,domain=-sqrt(5):sqrt(5),purple] {-x^2}
node[anchor=south west,pos=1, circle, inner sep=1pt, fill=white, font=\footnotesize]{$y=-\frac{a}{2}x^{2}$};

\end{axis}
\end{tikzpicture}

\end{document}

答案1

您的公式有大小字体\footnotesize(就我所见)。所以我只重新排列您的图片...

\documentclass{amsart}
%   \usepackage{mathtools,systeme,array}

\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}

\begin{document}
    \begin{tikzpicture}[
every node/.style={fill=white, inner sep=1pt,font=\footnotesize}
                    ]
\begin{axis}[width=3in,grid=both,
    grid style={line width=.1pt, draw=gray!10},
    clip=false,
    axis lines=middle,
    xmin=-3.5,xmax=3.5,
    ymin=-5.5,ymax=10.5,
    restrict y to domain=-5.5:10.5,
    xtick={-3,-2,...,3},ytick={},
    ticklabel style={font=\tiny},
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    xlabel=$x$,
    ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north east},
    ylabel style={at={(ticklabel* cs:1)},anchor=north west},
    axis on top
            ]
\addplot[samples=51,domain=-sqrt(5):sqrt(5),blue] {2*x^2}
node[anchor=north east,pos=0.25]{$y=ax^{2}$};

\addplot[samples=51,domain=-sqrt(5):sqrt(5),purple] {-x^2}
node[anchor=south west,pos=.9]{$y=-\dfrac{a}{2}x^{2}$};
\end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

你是否有特殊原因不使用最近的pgfplots?在上面的 MWE 中,我省略了它\usepackage{tikz},因为pgfplots也要加载它。

相关内容