我有以下问题。我想在方程环境中使用 tikz 图片。以下是一个最小示例:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
Some text here.
\begin{equation*}
\left[
\begin{tikzpicture}
\draw[thick] (1, -1) .. controls (0.4, -1) and (0, -0.6) .. (0, 0);
\draw[thick] (0, 0) .. controls (0, 0.6) and (0.6, 1) .. (1, 1);
\draw[thick] (1, -0.5) .. controls (0.7, -0.5) and (0.5, -0.3) .. (0.5, 0);
\draw[thick] (0.5, 0) .. controls (0.5, 0.3) and (0.7, 0.5) .. (1, 0.5);
\draw[thick] (1, -1) .. controls (1.5, -1) and (1.75, -0.6) .. (1.75, -0.25);
\draw[thick] (1, 0.5) .. controls (1.5, 0.5) and (1.75, 0.1) .. (1.75, -0.25);
\draw[thick] (1, -0.5) .. controls (1.5, -0.5) and (1.75, -0.1) .. (1.75, 0.25);
\draw[thick] (1, 1) .. controls (1.5, 1) and (1.75, 0.6) .. (1.75, 0.25);
\draw[dashed] (1, -1.1) -- (1, 1.1);
\end{tikzpicture}
\right]
\end{equation*}
Some more text here
\end{document}
现在,如果我删除“\left[...\right]”,那么它看起来就像预期的那样:
但上面代码的结果对我来说看起来出乎意料:
看起来好像图像在实际图形下包含另一个空白,如果没有括号则不会显示。我该如何去除这个空白?
答案1
由于您正在加载amsmath
,一种解决方案是使用环境bmatrix
来获取左括号和右括号。然后您可以保留 TikZ 代码原样。
代码
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{equation*}
\begin{bmatrix}
\begin{tikzpicture}
\draw[thick] (1, -1) .. controls (0.4, -1) and (0, -0.6) .. (0, 0);
\draw[thick] (0, 0) .. controls (0, 0.6) and (0.6, 1) .. (1, 1);
\draw[thick] (1, -0.5) .. controls (0.7, -0.5) and (0.5, -0.3) .. (0.5, 0);
\draw[thick] (0.5, 0) .. controls (0.5, 0.3) and (0.7, 0.5) .. (1, 0.5);
\draw[thick] (1, -1) .. controls (1.5, -1) and (1.75, -0.6) .. (1.75, -0.25);
\draw[thick] (1, 0.5) .. controls (1.5, 0.5) and (1.75, 0.1) .. (1.75, -0.25);
\draw[thick] (1, -0.5) .. controls (1.5, -0.5) and (1.75, -0.1) .. (1.75, 0.25);
\draw[thick] (1, 1) .. controls (1.5, 1) and (1.75, 0.6) .. (1.75, 0.25);
\draw[dashed] (1, -1.1) -- (1, 1.1);
\end{tikzpicture}
\end{bmatrix}
\end{equation*}
\lipsum[2]
\end{document}