你能帮我找出这段代码的问题吗?

你能帮我找出这段代码的问题吗?
\documentclass[12pt]{ucalgthes1}
\setcounter{secnumdepth}{4}
\usepackage[mathscr]{eucal}
\usepackage{cite}
\usepackage{tikz}
\usepackage[letterpaper,top=1in, bottom= 1in, left= 1in, right= 1in]{geometry}
\usepackage[braket]{qcircuit}

%\usepackage{fancyhdr}
%\fancyhead{}
%\fancyfoot{}
%\renewcommand{\headrulewidth}{0pt}
%\fancyhead[RO,LE]{\thepage}
%Define other usepackages here
\usepackage{enumitem}
\newlist{steps}{enumerate}{1}
\setlist[steps, 1]{label = Step \arabic*:}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{braket}
\usepackage{amssymb}
\usepackage{blindtext}
\usepackage{hyperref}
\usepackage{mathptmx}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{defn}{Definition}[section]
\usepackage[braket]{qcircuit}
\usepackage{subcaption}
\usepackage{psfrag}
\captionsetup{compatibility=false}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}






\begin{figure}
\centering
\begin{tikzpicture}
    \begin{tikzpicture}
    \node at (1.8,4.8) {n};
    \draw (1.8,2) circle (2.5cm) ;
    \draw (2.6,1.1) circle (1cm) node {$k$};
    \draw (1,2.9) circle (1cm) node {$k$};
    \draw [draw=blue,line width=3mm ,->,>=stealth] (2.1,2.9) -- (6,2.9);
    \draw [draw=blue,line width=3mm ,->,>=stealth] (3.7,1) -- (6,1);
    \node at (6.5,1) {$\ket{s}$};
    \node at (6.5,2.9) {$\ket{s}$};
\end{tikzpicture}
\label{fig:label}
\caption{Blah blah blah text.}
\end{figure}

\end{document}

答案1

这是对你的问题的一个最小解决方案。如果可以添加你的代码,也许可以重现你的错误。

\documentclass[]{article}
\usepackage{tikz}
\usepackage{braket}
\begin{document}

\begin{figure}[]
\centering
\begin{tikzpicture}
    \node at (1.8,4.8) {n};
    \draw (1.8,2) circle (2.5cm) ;
    \draw (2.6,1.1) circle (1cm) node {$k$};
    \draw (1,2.9) circle (1cm) node {$k$};
    \draw [draw=blue,line width=3mm ,->,>=stealth] (2.1,2.9) -- (6,2.9);
    \draw [draw=blue,line width=3mm ,->,>=stealth] (3.7,1) -- (6,1);
    \node at (6.5,1) {$\ket{s}$}; 
    \node at (6.5,2.9) {$\ket{s}$}; 
\end{tikzpicture}
\caption{Blah blah blah text.}
\label{fig:label}
\end{figure}

\end{document}

编辑

这是您的代码,可以处理所有问题(除了没有软件包被加载两次)。最好修复它,因为修复代码时会犯更多错误。下次与 MWE 合作。你会帮助自己的。

\documentclass[12pt]{article}
\setcounter{secnumdepth}{4}
\usepackage[mathscr]{eucal}
\usepackage{cite}
\usepackage{tikz}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[braket]{qcircuit}

%\usepackage{fancyhdr}
%\fancyhead{}
%\fancyfoot{}
%\renewcommand{\headrulewidth}{0pt}
%\fancyhead[RO,LE]{\thepage}

%% Load other packages here

\usepackage{enumitem}
\newlist{steps}{enumerate}{1}
\setlist[steps, 1]{label = Step \arabic*:}

\usepackage{caption,subcaption}
\captionsetup{compatibility=false}   % is this really needed??

\usepackage{graphicx}
\usepackage{mathtools}
%\usepackage{amsmath} % is loaded automatically by 'mathtools' package
\usepackage{braket}
\usepackage{amssymb}
\usepackage{blindtext}
%\usepackage{hyperref} % don't load this package twice!
\usepackage{mathptmx}

\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{defn}{Definition}[section]

%\usepackage[braket]{qcircuit} % has already been loaded 
\usepackage{psfrag}
% \usepackage{amsmath}  % has already been loaded 
% \usepackage{amssymb}  % has already been loaded 
\usepackage{dsfont}

\usepackage{hyperref} % load this package *last*

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
       \node at (1.8,4.8) {n};
    \draw (1.8,2) circle (2.5cm) ;
    \draw (2.6,1.1) circle (1cm) node {$k$};
    \draw (1,2.9) circle (1cm) node {$k$};
    \draw [draw=blue,line width=3mm ,->,>=stealth] (2.1,2.9) -- (6,2.9);
    \draw [draw=blue,line width=3mm ,->,>=stealth] (3.7,1) -- (6,1);
    \node at (6.5,1) {$\ket{s}$};
    \node at (6.5,2.9) {$\ket{s}$};
\end{tikzpicture}
\caption{Blah blah blah text.}
\label{fig:label}
\end{figure}

\end{document}

答案2

我认为你的意思是这个类模板。它使用doublespace已过时的软件包。使用setspace反而似乎修复了您可能遇到的错误(! Too many }'s. \color@endbox ->\color@endgroup \egroup)。

我对文件所做的更改ucalgthes1.cls使其正常工作:

  • 替换\input doublespace.sty %(nm 2007 re-instated)\RequirePackage{setspace}
  • \let\@currsize\normalsize在最后一行之前添加( \setstretch{1.7}) - 参见这个问题寻求解释。

现在,以下 MWE 应该可以工作了(答案的清理版本傻瓜):

\documentclass[12pt]{ucalgthes1}

\usepackage{tikz}
\usepackage{braket}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
    \node at (1.8,4.8) {$n$};
    \draw (1.8,2) circle (2.5cm) ;
    \draw (2.6,1.1) circle (1cm) node {$k$};
    \draw (1,2.9) circle (1cm) node {$k$};
    \draw [draw=blue,line width=3mm ,->,>=stealth] (2.1,2.9) -- (6,2.9);
    \draw [draw=blue,line width=3mm ,->,>=stealth] (3.7,1) -- (6,1);
    \node at (6.5,1) {$\ket{s}$};
    \node at (6.5,2.9) {$\ket{s}$};
\end{tikzpicture}
\caption{Blah blah blah text.}
\label{fig:label}
\end{figure}

\end{document}

注意:似乎 2005 年对该模板进行了更改,setspace但 2007 年又恢复了该模板:%\RequirePackage{setspace}[200/12/01] %(NM2005) replacing old doublespace.sty %singlespace,onehalfspace and doublespacing options. (nm2007 commented out)%

相关内容