我正在嘗試編譯這段程式碼
\documentclass[a4paper, 11pt]{article}
\input{Preambule.tex}
\input{Commands.tex}
\begin{document}
%\maketitle
\begin{center}
\Large \WorkTitle \\
\Large \today
\end{center}
%\tableofcontents
\section{Introduction}
\figz{Pictures/mx.png}{4cm}{lab1}{Pictures/mx.png}{4cm}{lab2}{big cap}{fig:mux}
\figi{Pictures/mx.png}{8cm}{label}
\end{document}
指令 \figz 來自 {Commands.tex} 指令定義如下:
%Simple figure
\newcommand{\figi}[3]{
\begin{figure}[!ht]
\begin{center}
\includegraphics[width=#2]{#1}
\end{center}
\caption{\label{#1}#3}
\end{figure}
}
%two figures side by side
%inputs
% #1 figpath1 // #2 fig1 size // #3 labelfig1
% #4 figpath2 // #5 fig2 size // #6 labelfig2
% #7 fig lgd // #8 fig ref
\newcommand{\figz}[8]{
\begin{figure}[!ht]
\centering
\subfloat[\centering #3]{{\includegraphics[width=#2]{#1} }}%
\qquad
\subfloat[\centering #6]{{\includegraphics[width=#5]{#4} }}%
\caption{#7}%
\label{#8}%
\end{figure}
}
每當我嘗試編譯此命令時,都會收到錯誤“未定義的控制序列”。最奇怪的是,我在一些舊文件中使用了完全相同的命令,但從未遇到過這個問題。從今天起我就可以編譯它們了。 “Commands.tex”中定義的 \figi 指令不會回報任何錯誤。
我正在使用 VScode 和 James Yu 擴展的 LaTex Workshop。
關於錯誤從何而來的任何想法?
答案1
經過一番查找後,我意識到我沒有將其包含\usepackage{subfig}
在我的Preamble.tex
文件中。現在問題已經解決了...