对于我的论文,我想将各种 tex 文档编译为章节。不幸的是,当我尝试链接各个章节时,我收到以下错误:
文件:chapter_1/tex/chapter1 "!缺失数字,视为零。}\section{introduction}
文件:chapter_1/tex/chapter1 "!计量单位非法(插入 pt)。}\section{introduction}
以下是我的 LaTex 代码片段:
编译器的主要文件即各个章节:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass
[
paper=a4, % choose page size e.g. a4 or b5 (common booklet size)
fontsize=12pt,
headings=big,
parskip, %indent at paragrafs?
numbers=noendperiod, % 2.3.1 vs 2.3.1. (no dot after the last chapter number)
twoside=true, %choose two sided for a booklet style, semi leaves the margings the same
headinclude,
pagesize,
appendixprefix=false,
headsepline,
toc=bibliography, % Bibliography appears in Table of Contents (without a number)
version=last % Use latest version of the KOMA-Script
]{Thesis_Template}
% Add the configuration and packages
\input{definitions/configuration}
\input{definitions/packages_commands}
\input{definitions/hyphenation}
% ad hoc settings
\interfootnotelinepenalty=10000
%import packages that need to be imported separately
\usepackage[subpreambles=false]{standalone}
\usepackage{import}
%toggle for footnotes to continue over the chapters
\counterwithout{footnote}{chapter}
\flipbindingmargins
% ad hoc spacing for sections
\setlength\parskip{1em plus 0em minus 0.1em}
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{1em plus 0em minus 0.1em}{1em plus 0em}
\titlespacing*{\subsection}{0pt}{1em plus 0em minus 0.1em}{.6em plus 0em}
\titlespacing*{\subsubsection}{0pt}{1em plus 0em minus 0.1em}{.6em plus 0em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\frontmatter
\headerpage
%% Startmain content
\mainmatter
\chapter[Chapter 1]{Chapter 1 long title} \label{chapt 1}
%import actual chapter tex
\import{chapter_1/tex/}{chapter1}
\end{document}
章节示例代码:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,11pt]{article}
\usepackage{standalone} \standalonetrue %to allow it to be part of thesis
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{fullpage}
\usepackage{fancyvrb}
\usepackage{amsmath}
\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage[flushleft]{threeparttable}
\usepackage{amsthm}
\usepackage{tikzscale}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{bm}
\usepackage{bibentry}
\usepackage{natbib}
\usepackage{csquotes}
\usepackage{booktabs}
\usepackage[font=small]{caption}
\usepackage{nameref}
\usepackage{caption}
\usepackage[toc,page]{appendix}
\usepackage{tabularx}
\usepackage{subcaption}
\usepackage{subfiles}
\usepackage{mathrsfs}
\usepackage{standalone}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{setspace}
\usepackage{dcolumn}
\usepackage{cleveref}
\usepackage[nomessages]{fp}
\usepackage{ifthen}
\usepackage{tablefootnote}
%Settings
\tolerance=2000
\usepackage[usenames,dvipsnames]{color}
\hypersetup{
colorlinks,
citecolor=blue,
linkcolor=blue,
urlcolor=blue
}
\usepackage{tikz}
\usepackage{pst-plot}
\usepackage{pst-func}
\usepackage{animate}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}
%sections setup
\titleformat{\section}{\normalfont\bfseries}{\thesection.}{.5em}{\hyperlink{toc}{{\black{#1}}}}
\titleformat{\subsection}{\normalfont}{\thesubsection.}{.5em}{\hyperlink{toc}{\it{\black{#1}}}}
\titleformat{\subsubsection}{\normalfont}{\thesubsubsection.}{.5em}{\it{#1}}
\titlespacing*{\subsubsection}{0pt}{11pt}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\ifstandalone
\title{\sc{Title}
\unskip\thanks{Thanks to ...}
}
\author{John Doe}
}
\date{\today}
\maketitle
\vspace{-1.5em}
%%%%%%% ABSTRACT %%%%%%%
\begin{center}
\parbox[t]{.9\textwidth}{
\begin{small}
\singlespacing
Abstract text here.
\clearpage
\doublespacing
\fi
%%%%%%% Introduction %%%%%%%
\section{Introduction}
Introduction text here
\end{document}
我正在使用 TeX Maker。我还确保所有软件包都是最新的。
我在网上看到其他帖子说这可能与标题安全包,但无法找到解决方案。
非常感谢您的支持!
答案1
该\import
命令基于命令,它基本上将指向的文件粘贴到/\input
的位置。其中包括和其余的前言。当然,这是行不通的!\input
\import
\documentclass
相反,你应该使用subfiles
包。请参阅如何将现有的 LaTeX 文件作为论文附录的章节?
我不完全确定这是怎么回事,因为我得到了更具描述性的错误Can be used only in preamble
。但是,我使用了一个非常干净的最小文档,并且随着配置的增加,事情变得更容易混淆。