Tikz 示例无法编译

Tikz 示例无法编译

我正在尝试编译 PGF 手册中的一个示例,但遇到了很多错误。以下是代码

\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);

\draw [name path=A--B] (A) -- (B);

\node (D) [name path=D,draw,circle through=(B),label=left:$D$] at (A) {};
\node (E) [name path=E,draw,circle through=(A),label=right:$E$] at (B) {};

\path [name intersections={of=D and E, by={[label=above:$C$]C, [label=below:$C’$]C’}}];

\draw [name path=C--C’,red] (C) -- (C’);

\path [name intersections={of=A--B and C--C’,by=F}];
\node [fill=red,inner sep=1pt,label=-45:$F$] at (F) {};
\end{tikzpicture}

顺便说一下,这里是我正在使用的库,我将它们全部发布只是因为在过去它们被证明是问题所在。

\documentclass[letterpaper]{article}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-lcroman]{babel}
\usepackage{parskip}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz-cd}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing,calc,intersections,through,backgrounds}
\pgfplotsset{compat=newest}

另外,您要知道,我在 Linux 上使用 LaTeX,并且安装了 texlive-full 包,我认为它应该包含我需要的所有工具。

代码的问题似乎出在这行

\path [name intersections={of=D and E, by={[label=above:$C$]C, [label=below:$C’$]C’}}];

提前感谢您提供的任何帮助。

在这里,我发布了日志文件中的一些错误消息以回应评论:

l.61 ...=above:$C$]C, [label=below:$C’$]C’}}];

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
                   \begingroup 
l.61 ...=above:$C$]C, [label=below:$C’$]C’}}];

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

l.63                    \draw [name path=C--C’,red] (C)
                                            -- (C’);
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

答案1

错误在于使用C’而不是无向引号C';撇号不适合用作节点名称,就像其他非 ASCII 字符一样。但在公式中,最好使用$C'$而不是$C’$,因为那不是撇号。

\documentclass[letterpaper]{article}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-lcroman]{babel}
\usepackage{parskip}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz-cd}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing,calc,intersections,through,backgrounds}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (0,0);
\coordinate [label=right:$B$] (B) at (1.25,0.25);

\draw [name path=A--B] (A) -- (B);

\node (D) [name path=D,draw,circle through=(B),label=left:$D$] at (A) {};
\node (E) [name path=E,draw,circle through=(A),label=right:$E$] at (B) {};

\path [name intersections={of=D and E, by={[label=above:$C$]C, [label=below:$C'$]C'}}];

\draw [name path=C--C',red] (C) -- (C');

\path [name intersections={of=A--B and C--C',by=F}];
\node [fill=red,inner sep=1pt,label=-45:$F$] at (F) {};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容