我正在尝试编写一本 LaTeX 书,当我使用\newtheorem{definition}{Definition}[section]
注释时,发生了一件奇怪的事情:当我仅将命令放在主文件中时,主 TeX 可以完美运行,但是当我将此命令放在子文件中时,我收到如下错误:
LaTeX 错误:命令 \definition 已定义。
或者名称 \end... 非法,请参阅手册第 192 页。
请帮忙,我花了几个小时在网上搜索,但没有一个能帮助我。
更新:可以通过删除以下命令来解决这个问题:
\usepackage[subpreambles=true]{standalone}
但这并不理想,因为当我尝试在不同的章节中编写它时,编译时间会更长。那么有没有办法在不删除功能的情况下解决这个问题standalone
?
是main.tex
:
\documentclass[11pt,a4paper]{book}
\usepackage[subpreambles=true]{standalone}
\usepackage[pdfencoding=auto]{hyperref}
\usepackage{graphicx,graphics,fancyhdr,lastpage,color,framed,amsmath,ntheorem,amssymb,cool,textcomp,subfiles,datetime,url,float,cases,mathtools,mathrsfs,inputenc,geometry,siunitx,enumitem,import,subfig,chngcntr,tabularx,sidecap,hhline}
\usepackage[toc,page]{appendix}
\usepackage[capitalise]{cleveref}
\usepackage[version=4]{mhchem}
%\graphicspath{{images/}{../images/}}
\usepackage{eso-pic}
\geometry{a4paper,left=11mm,right=17mm,top=20mm,bottom=20mm}
\renewcommand\labelitemi{---}
\providecommand*\diff{\mathop{}\!\mathrm{d}}
\providecommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}
\providecommand*{\e}{\mathrm{e}}
\sisetup{parse-numbers = false}
\setlength\parindent{0pt}
\setlist[itemize]{noitemsep, topsep=0pt}
\numberwithin{equation}{section}
\providecommand*{\myTagFormat}[2]{(\ref{#1})($#2$)}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\sidecaptionvpos{figure}{t}
%\title{Summary of Introducing the Stars}
\author{}
\date{}
% \usepackage{fontspec}
% \setmainfont{segoeuil.ttf}
\raggedbottom
\begin{document}
\thispagestyle{empty}
\begingroup
\AddToShipoutPictureBG*{\includegraphics[scale=0.2,height=\paperheight]{cover}};
\centering
\vspace*{5cm}
\par\normalfont\fontsize{35}{35}\sffamily\selectfont
\textbf{SUMMARY OF INTRODUCING THE STARS}
\endgroup
\tableofcontents
\newpage
\import{chapters/}{"C1"}
\newpage
\import{chapters/}{"C2"}
\newpage
\end{document}
我的子文件C1.tex
是
\documentclass[11pt,a4paper]{book}
\usepackage[subpreambles=true]{standalone}
\usepackage[pdfencoding=auto]{hyperref}
\usepackage{graphicx,graphics,fancyhdr,lastpage,color,framed,amsmath,ntheorem,amssymb,cool,textcomp,subfiles,datetime,url,float,cases,mathtools,mathrsfs,inputenc,geometry,siunitx,enumitem,import,subfig,chngcntr,tabularx,sidecap,hhline}
\usepackage[toc,page]{appendix}
\usepackage[capitalise]{cleveref}
\usepackage[version=4]{mhchem}
\geometry{a4paper,left=11mm,right=17mm,top=20mm,bottom=20mm}
\renewcommand\labelitemi{---}
\providecommand*\diff{\mathop{}\!\mathrm{d}}
\providecommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}
\providecommand*{\e}{\mathrm{e}}
\sisetup{parse-numbers = false}
\setlength\parindent{0pt}
\setlist[itemize]{noitemsep, topsep=0pt}
\numberwithin{equation}{section}
\providecommand*{\myTagFormat}[2]{(\ref{#1})($#2$)}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\sidecaptionvpos{figure}{t}
\newtheorem{definition}{Definition}[section]
\begin{document}
\begin{definition}
\newcounter{1.1}The luminosity $(L)$ is the total amount of energy radiated by a star overall wavelengths of electromagnetic radiation per second into space. The units of luminosity are Joules per second, or Watts.
\end{definition}
\end{document}
我的第二个子文件是
\documentclass[11pt,a4paper]{book}
\usepackage[subpreambles=true]{standalone}
\usepackage[pdfencoding=auto]{hyperref}
\usepackage{graphicx,graphics,fancyhdr,lastpage,color,framed,amsmath,ntheorem,amssymb,cool,textcomp,subfiles,datetime,url,float,cases,mathtools,mathrsfs,inputenc,geometry,siunitx,enumitem,import,subfig,chngcntr,tabularx,sidecap,hhline}
\usepackage[toc,page]{appendix}
\usepackage[capitalise]{cleveref}
\usepackage[version=4]{mhchem}
\geometry{a4paper,left=11mm,right=17mm,top=20mm,bottom=20mm}
\renewcommand\labelitemi{---}
\providecommand*\diff{\mathop{}\!\mathrm{d}}
\providecommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}
\providecommand*{\e}{\mathrm{e}}
\sisetup{parse-numbers = false}
\setlength\parindent{0pt}
\setlist[itemize]{noitemsep, topsep=0pt}
\numberwithin{equation}{section}
\providecommand*{\myTagFormat}[2]{(\ref{#1})($#2$)}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\sidecaptionvpos{figure}{t}
\newtheorem{definition}{Definition}[section]
\begin{document}
\chapter{Star Formation}
\begin{definition}
\newcounter{2.1}test
\end{definition}
\end{document}