谁能告诉我如何在数组环境中对齐字母 A、B、C、D 和 E,以便我可以将它们分别移动到黄点?
我已在下面附加我的代码
\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\setlength{\parindent}{0cm}
\textbf{Question 16}\\
The graph of the function $y=f(x)$ is shown below
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
title={$ $},
xlabel={$ $}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.1,ymax=0.45,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
\end{center}
The corresponding part of the graph of the derivative function $y = f'(x)$ is best represented by
\begin{center}
\setlength\arraycolsep{5pt} % default is "5pt"
$\begin{array}{cccc}
\textbf{A.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{-0.01\height}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}} &
\textbf{B.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
title={$ $},
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{-0.01\height}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}\\
\textbf{C.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{-0.01\height}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {-x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}} &
\textbf{D.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{-0.01\height}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}\\
\textbf{E.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{-0.01\height}{
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.45,ymax=0.1,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}
\end{array}$
\end{center}
\end{document}
答案1
通过确定边界框顶部周围的绘图基线,可以实现 A、B、C、D 和 E 与绘图顶部所需的垂直对齐:
在下面的 MWE 代码中
\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usetikzlibrary{calc}% <-- new
\tikzset{plotalign/.style = {baseline={([yshift=-1em] current bounding box.north)}}}% <-- new
\usepackage{array,booktabs}% <-- new
\setlength{\parindent}{0cm}
\pgfplotsset{every axis/.append style={% <-- now common for all plots
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\begin{document}
\textbf{Question 16}\\
The graph of the function $y=f(x)$ is shown below
\begin{center}
\begin{tikzpicture}
\begin{axis}[scale=0.9,
xmin=-4,xmax=4,
ymin=-0.1,ymax=0.45,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
\end{center}
The corresponding part of the graph of the derivative function $y = f'(x)$ is best represented by
\begin{center}
\begin{tabular}{>{\bfseries}c c >{\bfseries}c c}
A. &
\begin{tikzpicture}[plotalign]
\begin{axis}[scale=0.9,
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
& B. &
\begin{tikzpicture}[plotalign]
\begin{axis}[scale=0.9,
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture} \\
\addlinespace
C. &
\begin{tikzpicture}[plotalign]
\begin{axis}[scale=0.9,
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {-x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
& D. &
\begin{tikzpicture}[plotalign]
\begin{axis}[scale=0.9,
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture} \\
\addlinespace
E. &
\begin{tikzpicture}[plotalign]
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.45,ymax=0.1,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{center}
\end{document}
添加了两个包:array
和booktabs
,其中定义了\tikzset
用于对齐图标签(A、B、...、E)和图顶部的样式。此外,\plotsset
对于所有图,在序言中只定义了 1,因为它们在所有这些图中都是相等的。这样代码就更简洁了。构造 $\begin{array} ...\end{array} , which intention/benefits are not clear to me, is replaced with
tabular` 环境。
可以看出,所有\raisebox
框都被省略了。表格设计中也包含一些小的变化:用addlinespace
从booktabs
确定表格行之间的空间,scale
可以省略而不会对图产生明显变化,从移动tikzpicture
到axes
更合适的位置(关于图中字体的缩放)。
答案2
你应该降低 将stikzpicture
乘以 their \height
(或将其提高-\height
),以及对基线跳过的修正,在 下,array
存储在 中\normalbaselineskip
。由于tikzpicture
的边框周围有更多空白,我们可以将其\normalbaselineskip
增加到1.5\normalbaselineskip
:
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\setlength{\parindent}{0cm}
\textbf{Question 16}\\
The graph of the function $y=f(x)$ is shown below
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
title={$ $},
xlabel={$ $}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.1,ymax=0.45,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}
\end{center}
The corresponding part of the graph of the derivative function $y = f'(x)$ is best represented by
\begin{center}
\setlength\arraycolsep{5pt} % default is "5pt"
$\begin{array}{cccc}
\textbf{A.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{\dimexpr-\height+1.5\normalbaselineskip}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}} &
\textbf{B.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
title={$ $},
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{\dimexpr-\height+1.5\normalbaselineskip}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}\\
\textbf{C.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{\dimexpr-\height+1.5\normalbaselineskip}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {-x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}} &
\textbf{D.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{\dimexpr-\height+1.5\normalbaselineskip}{
\begin{tikzpicture}
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.8,ymax=0.8,
]
\addplot[thick,samples=100,domain=-3.5:0] {x*exp(-x^2/2)/sqrt(2*pi)};
\addplot[thick,samples=100,domain= 0:3.5] {-x*exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}\\
\textbf{E.} &
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
ticks=none
}}
\raisebox{\dimexpr-\height+1.5\normalbaselineskip}{
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
ylabel={$ $}, % default put y on y-axis
xmin=-4,xmax=4,
ymin=-0.45,ymax=0.1,
]
\addplot[thick,samples=100,domain=-3.5:3.5] {-exp(-x^2/2)/sqrt(2*pi)};
\end{axis}
\end{tikzpicture}}
\end{array}$
\end{center}
\end{document}