抱歉,我的问题标题不清楚。我是 latex 新手。我从网上复制了这个模板。修改后,我收到这个错误,我搞不懂。
! Undefined control sequence.
\f@ncyoch ...hmwkClassInstructor \ \hmwkClassTime
): \hmwkTitle \strut
l.211 \]
这是我的文字:
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage[plain]{algorithm}
\usepackage{algpseudocode}
\usetikzlibrary{automata,positioning}
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in
\linespread{1.1}
\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{\thepage}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt}
\newcommand{\enterProblemHeader}[1]{
\nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}
\newcommand{\exitProblemHeader}[1]{
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\stepcounter{#1}
\nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}
\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}
\newenvironment{homeworkProblem}[1][-1]{
\ifnum#1>0
\setcounter{homeworkProblemCounter}{#1}
\fi
\section{Problem \arabic{homeworkProblemCounter}}
\setcounter{partCounter}{1}
\enterProblemHeader{homeworkProblemCounter}
}{
\exitProblemHeader{homeworkProblemCounter}
}
\newcommand{\hmwkTitle}{Homework\ \#4}
\newcommand{\hmwkDueDate}{May 07, 2015}
\newcommand{\hmwkClass}{Laser Physics I}
\newcommand{\hmwkClassInstructor}{Professor Kyuman Cho}
\newcommand{\hmwkAuthorName}{Seng Sopheak}
\title{
\vspace{2in}
\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\
\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate\ at 23:59}\\
\vspace{0.1in}\large{\textit{\hmwkClassInstructor}}
\vspace{3in}
}
\author{\textbf{\hmwkAuthorName}}
\date{}
\renewcommand{\part}[1]{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}\\}
\newcommand{\alg}[1]{\textsc{\bfseries \footnotesize #1}}
% For derivatives
\newcommand{\deriv}[1]{\frac{\mathrm{d}}{\mathrm{d}x} (#1)}
% For partial derivatives
\newcommand{\pderiv}[2]{\frac{\partial}{\partial #1} (#2)}
% Integral dx
\newcommand{\dx}{\mathrm{d}x}
% Alias for the Solution section header
\newcommand{\solution}{\textbf{\large Solution}}
% Probability commands: Expectation, Variance, Covariance, Bias
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Bias}{\mathrm{Bias}}
\begin{document}
\maketitle
\pagebreak
\begin{homeworkProblem}
\textbf{A Plano-Concave Resonator.} When mirror $1$ is planar $\left(R_1=\infty\right)$, determine the confinement condition and the depth of focus, as well as the beam width at the waist and at each of the mirrors, as a function of $\frac{d}{\left|R_2\right|}$.\\
\textbf{Solution}
\textbf{Confinement Condition}
\\
Note that:
\[
\begin{split}
R_1&=z_1\left[z_1+\left(\frac{z_0}{z_1}\right)^2\right]
\\
&=\infty
\\
\Rightarrow z_1&=0
\\
z_2&=z_1+d
\\&=0+d
\\
&=d\\
\end{split}
\]
Confinement Condition:\\
\[
\begin{array}{r c l}\quad 0\leq&\left(1+\frac{d}{R_1}\right)\left(1+\frac{d}{R_2}\right)&\leq1\\
0\leq&\left(1+\frac{d}{\infty}\right)\left(1+\frac{d}{\left|R_2\right|}\right)&\leq1\\
0\leq&\left(1+\frac{d}{\left|R_2\right|}\right)&\leq1\\
\Rightarrow1\geq&\frac{d}{\left|R_2\right|}&\geq0
\end{array}
\]
\textbf{Depth of Focus}
\\
From\\
\[
\begin{split}
|R_2|&=z_2\left[z_2+\left(\frac{z_0}{z_2}\right)^2\right]
\\
\Rightarrow z_0^2&=z_2R_2-z_2^2
\\
&=dR_2-d^2
\\
\Rightarrow z_0&=\sqrt{dR_2-d^2}
\\
\textrm{Or }2z_0&=2d\sqrt{\frac{\left|R_2\right|}{d}-1}\\
\end{split}
\]
\textbf{Beam Width}
\\
At the plane mirror\\
\[
\begin{split}
W\left(z_1\right)&=W_0\sqrt{1+\left(\frac{z_1}{z_0}\right)^2}
\\
&=W_0\sqrt{1+\left(\frac{\infty}{z_0}\right)^2}
\\
&=W_0
\end{split}
\]\\
At the concave mirror\\
\[
\begin{split}
W\left(z_2\right)&=W_0\sqrt{1+\left(\frac{z_2}{z_0}\right)^2}
\\
&=W_0\sqrt{1+\left(\frac{d}{d\sqrt{\frac{R_2}{d}-1}}\right)^2}
\\
&=W_0\sqrt{1+\frac{d}{R_2-d}}
\end{split}
\]
\end{homeworkProblem}
\end{document}
抱歉,复制太长了。我不知道错误在哪里,也不知道到底是什么。谢谢
答案1
错误消息非常清楚,\hmwkClassTime
未定义。因此请定义它或将其删除。
答案2
原始模板称为结构化通用在模板站点的作业部分。
我们可以找
\newcommand{\hmwkClassTime}{10:30am} % Class/lecture time
由于多次使用,因此请清空参数以防止出现错误。
\newcommand{\hmwkClassTime}{} % Class/lecture time
需要注意的是,模板似乎是开始学习 LaTeX 的好主意,但事实并非如此。LaTeX 编码大多很糟糕,是一个非常糟糕的例子,不应用作起点。