TikZ 图表并排对齐

TikZ 图表并排对齐

我有一个关于旋转体问题的解决方案。在我的电脑上,TikZ 没有对图形之间的区域进行着色。marmot以下提供的代码关联确实遮蔽了该区域。

如何正确地将图形的绘图放在解决方案的右侧。在我的计算机上,绘图超出了右侧边缘?

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

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

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}
\noindent \textbf{1.) }Determine the volume of the solid obtained by rotating about the \textit{x}-axis the region bounded by the standard parabola $y = x^{2}$ and the graph of the square root function $y = \sqrt{x}$.
\vskip0.2in

\noindent \textbf{Evaluation of the volume via the cylindrical shells method} \vskip1.25mm
\noindent \begin{minipage}[t]{6in}
\noindent \raggedright{The volume of the solid obtained by rotating about the \textit{x}-axis the \\
region in the $\mathit{xy}$-plane bounded by the parabola and the graph of \\
the square root function $y = \sqrt{x}$ is}
\begin{align*}
&2\pi \int_{0}^{1} y \left[\sqrt{y} - y^{2}\right] \, \mathit{dy} \\
&\qquad = 2\pi \int_{0}^{1} \left[y^{3/2} - y^{3}\right] \, \mathit{dy} \\
&\qquad = 2\pi \left[\frac{2}{5} y^{5/2} - \frac{1}{4} \, y^{4}\right] \left.{\vphantom{\displaystyle{\int_{0}^{1}}}}\right\vert_{0}^{1} \\
&\qquad = 2\pi \left[\frac{2}{5} - \frac{1}{4} \right] \\
&\qquad = \frac{3\pi}{10} . \ \rule{1.5ex}{1.5ex}
\end{align*}
\end{minipage}
%
\hspace{-0.25cm}
%
\raisebox{0mm}[0mm][0mm]
{
\begin{tikzpicture}[baseline=(current bounding box.north west)]
\begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
    axis lines=middle,
    xmin=-2,xmax=4, domain=-2:4,
    ymin=-0.75,ymax=4,
    restrict y to domain=-0.75:4,
    xtick={\empty},ytick={\empty},
    axis lines=middle,
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
    xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
    ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]

%The graphs of the square root function and the standard parabola are plotted.
\addplot[samples=501, name path=parabola, domain=-2:2] {x^2};
\addplot[samples=501, name path=root, domain=0:4] {sqrt(x)};


%The region between the graphs of the two functions is shaded.
\addplot[gray!50] fill between [of=parabola and root, soft clip={domain=0:1}];


%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
\coordinate (A) at (-15/8,225/64);
\coordinate (B) at (-15/16,0);

%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
\coordinate (P) at (15/4,{sqrt(15/4)});
\coordinate (Q) at (0,{1/4*sqrt(15)});

\end{axis}


%A "pin" is drawn to A.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0,  font=\scriptsize]{\makebox[0pt][r]{$y=x^{2}$}};

%A "pin" is drawn to P.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
\node[anchor=north, inner sep=0, outer sep=0, font=\scriptsize] at ($(P)!0.4cm!90:(Q)$){\makebox[0pt][l]{$y=\sqrt{x}$}};

\end{tikzpicture}
}


\end{document}

答案1

实际上,您已经做好了一切准备,只需调整水平和垂直位移的值即可获得更好的结果。即提供给\hspace和 的值\raisebox

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}

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

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}

\noindent \textbf{1.) }Determine the volume of the solid obtained by rotating about the \textit{x}-axis the region bounded by the standard parabola $y = x^{2}$ and the graph of the square root function $y = \sqrt{x}$.
\vskip0.2in

\noindent \textbf{Evaluation of the volume via the cylindrical shells method} \vskip1.25mm
\noindent \begin{minipage}[t]{6in}
\noindent \raggedright{The volume of the solid obtained by rotating about the \textit{x}-axis the \\
region in the $\mathit{xy}$-plane bounded by the parabola and the graph of \\
the square root function $y = \sqrt{x}$ is}
\begin{align*}
&2\pi \int_{0}^{1} y \left[\sqrt{y} - y^{2}\right] \, \mathit{dy} \\
&\qquad = 2\pi \int_{0}^{1} \left[y^{3/2} - y^{3}\right] \, \mathit{dy} \\
&\qquad = 2\pi \left[\frac{2}{5} y^{5/2} - \frac{1}{4} \, y^{4}\right] \left.{\vphantom{\displaystyle{\int_{0}^{1}}}}\right\vert_{0}^{1} \\
&\qquad = 2\pi \left[\frac{2}{5} - \frac{1}{4} \right] \\
&\qquad = \frac{3\pi}{10} . \ \rule{1.5ex}{1.5ex}
\end{align*}
\end{minipage}
%
\hspace{-3.5cm}%
\raisebox{-1cm}{%
\begin{tikzpicture}[baseline=(current bounding box.north west)]
\begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
    axis lines=middle,
    xmin=-2,xmax=4, domain=-2:4,
    ymin=-0.75,ymax=4,
    restrict y to domain=-0.75:4,
    xtick={\empty},ytick={\empty},
    axis lines=middle,
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
    xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
    ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]

%The graphs of the square root function and the standard parabola are plotted.
\addplot[samples=501, name path=parabola, domain=-2:2] {x^2};
\addplot[samples=501, name path=root, domain=0:4] {sqrt(x)};


%The region between the graphs of the two functions is shaded.
\addplot[gray!50] fill between [of=parabola and root, soft clip={domain=0:1}];


%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
\coordinate (A) at (-15/8,225/64);
\coordinate (B) at (-15/16,0);

%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
\coordinate (P) at (15/4,{sqrt(15/4)});
\coordinate (Q) at (0,{1/4*sqrt(15)});

\end{axis}


%A "pin" is drawn to A.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0,  font=\scriptsize]{\makebox[0pt][r]{$y=x^{2}$}};

%A "pin" is drawn to P.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
\node[anchor=north, inner sep=0, outer sep=0, font=\scriptsize] at ($(P)!0.4cm!90:(Q)$){\makebox[0pt][l]{$y=\sqrt{x}$}};

\end{tikzpicture}}

\end{document}

enter image description here

答案2

我认为可以使用 par indent,但对于您的代码,需要进行一些小的改动:

enter image description here

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{showframe}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

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

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}
\noindent \textbf{1.)} Determine the volume of the solid obtained by rotating about the \textit{x}-axis the region bounded by the standard parabola $y = x^{2}$ and the graph of the square root function $y = \sqrt{x}$.

\bigskip

\noindent\textbf{Evaluation of the volume via the cylindrical shells method} 

\noindent The volume of the solid obtained by rotating about the $x$-axis the 
region in the $\mathit{xy}$-plane bounded by the parabola and the graph of 
the square root function $y = \sqrt{x}$ is

\noindent\begin{minipage}[t]{.6\linewidth}
\begin{align*}
2\pi \int_{0}^{1} y \bigl(\sqrt{y} - y^{2}\bigr) \, dy 
&= 2\pi \int_{0}^{1} \bigl(y^{3/2} - y^{3}\bigr) \, dy \\
& = 2\pi \Biggl(\frac{2}{5} y^{5/2} - \frac{1}{4} \, y^{4}\Biggr) \Bigg\vert_{0}^{1} \\
& = 2\pi \Biggl(\frac{2}{5} - \frac{1}{4} \Biggr) \\
& = \frac{3\pi}{10} . \qed
\end{align*}
\end{minipage}%
\begin{minipage}[t]{.4\linewidth}\centering
\begin{tikzpicture}[baseline=(current bounding box.north west)]
\begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
    axis lines=middle,
    xmin=-2,xmax=4, domain=-2:4,
    ymin=-0.75,ymax=4,
    restrict y to domain=-0.75:4,
    xtick={\empty},ytick={\empty},
    axis lines=middle,
    axis line style={latex-latex},
    xlabel=\textit{x},ylabel=\textit{y},
    axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
    xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
    ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]

%The graphs of the square root function and the standard parabola are plotted.
\addplot[samples=501, name path=parabola, domain=-2:2] {x^2};
\addplot[samples=501, name path=root, domain=0:4] {sqrt(x)};


%The region between the graphs of the two functions is shaded.
\addplot[gray!50] fill between [of=parabola and root, soft clip={domain=0:1}];


%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
\coordinate (A) at (-15/8,225/64);
\coordinate (B) at (-15/16,0);

%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
\coordinate (P) at (15/4,{sqrt(15/4)});
\coordinate (Q) at (0,{1/4*sqrt(15)});

\end{axis}


%A "pin" is drawn to A.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0,  font=\scriptsize]{\makebox[0pt][r]{$y=x^{2}$}};

%A "pin" is drawn to P.
\draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
\node[anchor=north, inner sep=0, outer sep=0, font=\scriptsize] at ($(P)!0.4cm!90:(Q)$){\makebox[0pt][l]{$y=\sqrt{x}$}};

\end{tikzpicture}
\end{minipage}

\end{document}

答案3

与您的 mwe 相比,以下进行了以下更改:

  • 代替minipageraisebox使用tabularx
  • 设置\paraident为零,然后删除\noindentmwe 中的所有命令
  • 在方程中使用\dd来自physics包的命令
  • 页面大小和边距由包定义geometry(不清楚为什么不使用边框)
  • 图表的代码已重写,现在更简单、更简短

    \documentclass{amsart}
    \usepackage[margin=10pt, % you can restore to 0pt
                textwidth=6.1 in,
                textheight=9in]{geometry}  % <--- new
    \setlength\parindent{0pt}   % <--- new
    
    \usepackage{amsmath, amssymb}
    \usepackage{physics}        % <--- new
    \usepackage{tabularx}       % <--- new
    
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.11}
    \usepgfplotslibrary{fillbetween}
    \usetikzlibrary{intersections}
    
    \begin{document}
    \textbf{1.)}
    Determine the volume of the solid obtained by rotating about the \textit{x}-axis the region bounded by the standard parabola $y = x^{2}$ and the graph of the square root function $y = \sqrt{x}$.
    
    \medskip
    \textbf{Evaluation of the volume via the cylindrical shells method}
    
    \smallskip
    The volume of the solid obtained by rotating about the $x$-axis the region in the $xy$-plane bounded by the parabola and the graph of the square root function $y = \sqrt{x}$ is
    
        \medskip
    \begin{tabularx}{\linewidth}{ >{\raggedleft}X @{\qquad\qquad} X }
        $\begin{aligned}
    2\pi \int_{0}^{1} y \left[\sqrt{y} - y^{2}\right] \dd y
        & = 2\pi \int_{0}^{1} \left[y^{3/2} - y^{3}\right] \dd y                \\
        & = 2\pi \left.\left[\frac{2}{5} y^{5/2} - \frac{1}{4} \, y^{4}\right]
                 \right|_{0}^{1}                                                \\
        & = 2\pi \left[\frac{2}{5} - \frac{1}{4} \right]                        \\
        & = \frac{3\pi}{10} .   \quad\rule{1.5ex}{1.5ex}
        \end{aligned}$
        &
        \begin{tikzpicture}[baseline=(current bounding box.center)]
    \begin{axis}[height=2.25in,
                axis equal image,
                axis on top,
                clip=false,
                axis lines=middle,
                xmin=-2.5,  xmax=4.5,
                ymin=-0.5,  ymax=4.5,
                restrict y to domain=-0.75:4,
                xtick={\empty},ytick={\empty},
                axis line style={latex-latex},
                xlabel=$x$, ylabel=$y$,
                x label style={anchor=north east},
                y label style={anchor=north east},
                samples=101,
                ]
    %The graphs of the square root function and the standard parabola are plotted.
    \addplot[name path=parabola,
             domain=-2:2]   {x^2}     coordinate[pos=0.95,pin=0:{$y=x^2$}] (aux);
    \addplot[name path=root,
             domain= 0:4]   {sqrt(x)} coordinate[pos=0.85,pin=345:{$y=\sqrt{x}$}] (aux);
    %The region between the graphs of the two functions is shaded.
    \addplot[gray!50] fill between [of=parabola and root, soft clip={domain=0:1}];
        \end{axis}
    \end{tikzpicture}
        \end{tabularx}
    \end{document}
    

enter image description here

相关内容