我正在使用 lyx 编写一份较长的文档。我想在文档的图形标题中添加小型 tikz 代码。但是当我尝试运行它时,出现了以下错误。请帮我解决这个问题。
! Use of \use@pgfplotslibrary doesn't match its definition.
\pgfutil@ifnextchar ...1\def \pgfutil@reserved@a {
#2}\def \pgfutil@reserved@...
l.1411 ... method \label{fig:Velocity-curves-for}}
这是代码部分
\documentclass{svmono}
\usepackage{mathptmx}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{color}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{esint}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\DeclareRobustCommand{\greektext}{%
\fontencoding{LGR}\selectfont\def\encodingdefault{LGR}}
\DeclareRobustCommand{\textgreek}[1]{\leavevmode{%
\IfFileExists{grtm10.tfm}{}{\fontfamily{cmr}}\greektext #1}}
\DeclareFontEncoding{LGR}{}{}
\DeclareTextSymbol{\~}{LGR}{126}
\newcommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}
\text{\ifx\math@version\b@ld\bfseries\fi#1}\endgroup\else#1\fi}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage {tikz,pgfplots}
\usetikzlibrary{shapes,arrows,shadows,snakes}
\usepgfplotslibrary{colormaps}
\@ifundefined{showcaptionsetup}{}{%
\PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother
\begin{document}
\begin{figure}
\centering{}\caption{Velocity curves of the vehicle for 1$^{st}$ scenario. (a) DWA. \tikz[baseline]\draw[dashed,thick, color = blue](0ex,0ex)--(1ex,0ex);(b)
The proposed method \label{fig:Velocity-curves-for}}
\end{figure}
\end{document}
答案1
如果您要在章节标题或图形标题中使用 TikZ 图片,则需要“保护”它。
改变
\tikz[baseline]\draw[dashed,thick, color = blue](0ex,0ex)--(1ex,0ex);
到
\protect\tikz[baseline]\protect\draw[dashed,thick, color = blue](0ex,0ex)--(1ex,0ex);
有关详细信息,请参阅TeX FAQ 中关于保护的条目。