以下内容在 mactex 和 www.overleaf.com 上运行良好,但在我工作的地方的 CentOS 7 上运行不佳。
在 CentOS 上,我收到关于“软件包 tikz 错误:放弃此路径。您是否忘记了分号?”的投诉。
投诉是关于第 25 行,即我第一次使用 \r 的行。
我在 mactex 和 CentOS 上都使用 AUCTeX。我隐约觉得这与我使用“sin(..)”有关。
知道可能是什么问题吗?
% Geometry
% Author: MK
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
%%%>
\begin{comment}
:Title: Geometry
:Tags: Angles;Annotations;Basics;Mathematics;Geometry
:Author: MK
\end{comment}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\R{10};
\def\b{45};
\def\a{\b/2};
\def\r{\R*sin(\a)/(1+sin(\a))};
\draw[semithick] ({90+\a}:{\R-2*\r}) -- ({90+\a}:{\R});
\draw[dashed,semithick] (0,0) -- ({90+\a}:{\R-2*\r});
\draw[semithick] ({90-\a}:{\R-2*\r}) -- ({90-\a}:{\R});
\draw[dashed,semithick] (0,0) -- ({90-\a}:{\R-2*\r});
\draw[semithick] ({90+\a}:{\R}) arc ({90+\a}:{90-\a}:\R);
\draw[semithick] ({90+\a}:{\R-2*\r}) arc ({90+\a}:{90-\a}:{\R-2*\r});
\draw (0,{\R-\r}) circle (\r);
\end{tikzpicture}
\end{document}
答案1
感谢 marmot,它现在可以正常工作了。我将其更改\def\r{\R*sin(\a)/(1+sin(\a))}
为\pgfmathsetmacro{\r}{\R*sin(\a)/(1+sin(\a))}
工作示例:
% Geometry
% Author: MK
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
%%%>
\begin{comment}
:Title: Geometry
:Tags: Angles;Annotations;Basics;Mathematics;Geometry
:Author: MK
\end{comment}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\R{10};
\def\b{45};
\def\a{\b/2};
\pgfmathsetmacro{\r}{\R*sin(\a)/(1+sin(\a))};
\draw[semithick] ({90+\a}:{\R-2*\r}) -- ({90+\a}:{\R});
\draw[dashed,semithick] (0,0) -- ({90+\a}:{\R-2*\r});
\draw[semithick] ({90-\a}:{\R-2*\r}) -- ({90-\a}:{\R});
\draw[dashed,semithick] (0,0) -- ({90-\a}:{\R-2*\r});
\draw[semithick] ({90+\a}:{\R}) arc ({90+\a}:{90-\a}:\R);
\draw[semithick] ({90+\a}:{\R-2*\r}) arc ({90+\a}:{90-\a}:{\R-2*\r});
\draw (0,{\R-\r}) circle (\r);
\end{tikzpicture}
\end{document}