为什么下面的代码无法编译?(tikz 和范围)

为什么下面的代码无法编译?(tikz 和范围)

我有以下代码,用漂亮的 MWE 包装,但遗憾的是它无法编译。我的严重错误在哪里?=)

\documentclass{minimal}
\usepackage{tikz,tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tkzDefPoint(0,0){O}
\tkzDefPoint(1,2){A} \tkzDefPoint(3,0){B} \tkzDefPoint(4,2){C}
\tkzDrawSegments[ultra thick,-stealth,red](O,B)
\tkzDrawSegments[ultra thick,-stealth,blue](O,A)
\tkzDrawSegments[ultra thick,-stealth,green!40!black](B,A)
\tkzDrawSegments[ultra thick,-stealth](O,C)
\tkzDrawSegments[thick,-stealth,dashed](B,{3.8,1.6} A,{3.5,2})
\tkzLabelSegment[left,blue](O,A){\Large $u$} \tkzLabelSegment[below,red](O,B){\Large $v$}
\begin{scope}[shift={(0,1})]
\tkzLabelSegment[above=2ex,green!40!black](O,C){\Large $u+v$}
\end{scope}
\begin{scope}[shift={(1,1}]
\tkzLabelSegment[below=2ex](A,B){\Large $u-v$}
\end{scope}
\end{tikzpicture}
\end{document}

答案1

两件事情:

  1. 您交换了第一个中的)和的顺序,而忘记了第二个中的 。}shift)

  2. 您正在使用\Large,但minimal文档类不提供该尺寸。不要使用minimal

这是更正后的代码:

\documentclass{article}
\usepackage{tikz,tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tkzDefPoint(0,0){O}
\tkzDefPoint(1,2){A} \tkzDefPoint(3,0){B} \tkzDefPoint(4,2){C}
\tkzDrawSegments[ultra thick,-stealth,red](O,B)
\tkzDrawSegments[ultra thick,-stealth,blue](O,A)
\tkzDrawSegments[ultra thick,-stealth,green!40!black](B,A)
\tkzDrawSegments[ultra thick,-stealth](O,C)
\tkzDrawSegments[thick,-stealth,dashed](B,{3.8,1.6} A,{3.5,2})
\tkzLabelSegment[left,blue](O,A){\Large $u$} \tkzLabelSegment[below,red](O,B){\Large $v$}
\begin{scope}[shift={(0,1)}]
\tkzLabelSegment[above=2ex,green!40!black](O,C){\Large $u+v$}
\end{scope}
\begin{scope}[shift={(1,1)}]
\tkzLabelSegment[below=2ex](A,B){\Large $u-v$}
\end{scope}
\end{tikzpicture}
\end{document}

相关内容