如何在Latex环境中正确对齐Tikz图片以获得以下图片?
我的试用代码无法编译,
\documentclass[preview]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
A = \frac{%
\begin{tikzpicture}
\draw (0,0) to[bend left] (1,0) to[bend left] (0,0);
\end{tikzpicture}
}{%
\begin{tikzpicture}
\def\L{1.0}
\matrix[column sep=.1cm, row sep=2mm]
{
\draw (0,0) to[bend left] (\L,0) to[bend left] (0,0);
&
\node at (0,0) {$-$};
&
\draw[dashed] (0,0) -- (\L,0);
\draw[xshift=\L cm] (0,0) to[bend left] (\L,0) to[bend left] (0,0); \\
};
\end{tikzpicture}
}
\end{equation*}
\end{document}
答案1
通常,您可以使用选项控制垂直对齐baseline
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{equation*}
A = \frac{%
\begin{tikzpicture}[baseline={(0,-0.1)}]
\draw (0,0) to[bend left] (1,0) to[bend left] (0,0);
\end{tikzpicture}
}{%
\begin{tikzpicture}[baseline={(0,-0.1)}]
\draw (0,0) to[bend left] (1,0) to[bend left] (0,0);
\end{tikzpicture}
-
\begin{tikzpicture}[baseline={(0,-0.1)}]
\draw (0,0) to[bend left] (1,0) to[bend left] (0,0);
\draw[dashed](0,0) -- (-1,0);
\end{tikzpicture}
}
\end{equation*}
\end{document}
我不知道这些物体代表什么,所以您可能需要使用另一个基线。
请注意,您可以使用 Ti钾Z矩阵:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
A = \frac{%
\begin{tikzpicture}[baseline]
\draw (0,0) to[bend left] (1,0) to[bend left] (0,0);
\end{tikzpicture}
}{%
\begin{tikzpicture}[baseline]
\def\L{1.0}
\matrix[column sep=.1cm, row sep=2mm,ampersand replacement=\&]
{
\draw (0,0) to[bend left] (\L,0) to[bend left] (0,0);
\&
\node at (0,0) {$-$};
\&
\draw[dashed] (0,0) -- (\L,0);
\draw[xshift=\L cm] (0,0) to[bend left] (\L,0) to[bend left] (0,0); \\
};
\end{tikzpicture}
}
\end{equation*}
\end{document}
答案2
\documentclass{article}
\usepackage{tikz}
\begin{document}
\[
A = \frac{\tikz[baseline=1pt]{\draw (-1.5,0) to[bend left] (-0.5,0) to[bend left] (-1.5,0);}}
{\tikz{\draw (-1.5,0) to[bend left] (-0.5,0) to[bend left] (-1.5,0)
( 0.5,0) to[bend left] ( 1.5,0) to[bend left] ( 0.5,0);
\draw[dashed, shorten >=1mm, shorten <=1mm] (-0.5,0) -- (0.5,0);}
}
\]
\end{document}