将前导包放在不同的 tex 文件中

将前导包放在不同的 tex 文件中

我有以下主 tex 文件,我希望将命令放在\usepackage不同的usepackage.tex文件中并在主 tex 文件上进行编译。我该怎么做。我试过了,但一直出错,好像它不知道在哪里找到文件usepackages。(请原谅我把包裹弄得乱七八糟,我知道这是一场灾难,我现在正试图修复它。)

\documentclass[12pt,a4paper,twoside]{report}
\setlength{\textwidth}{16cm}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{setspace}
%\usepackage{biblatex}
%\usepackage{url}
\usepackage{epsfig}
\usepackage{filecontents}
\usepackage{xparse,nameref}
%\usepackage{hyperref}
\usepackage{mathrsfs}
\usepackage[nokeyprefix]{refstyle}
\usepackage{mathtools}
\usepackage{thmtools}
\usepackage{enumerate}% http://ctan.org/pkg/enumerate
\usepackage{enumitem}
\usepackage{thm-restate}
\usepackage{cleveref}
\usepackage{amsmath}
\usepackage{url}
\usepackage{amsthm}
\DeclareMathOperator{\lcm}{lcm}
\DeclareMathOperator{\ord}{ord}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{booktabs}
\setlength\defaultaddspace{2ex}
\usepackage{graphicx}
\usepackage{array}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage[figuresleft]{rotating}
\usepackage{rotating}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\swb{{\scriptstyle\Box}} % "small white box"
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\setcounter{secnumdepth}{3}
\usetikzlibrary{shapes.multipart}
\usepackage{tabu}
\usepackage{amssymb,bm}
\usepackage{framed}
\usepackage{upgreek} %use uptau greek letter
\usepackage{comment} %choose parts not to compile
\usepackage{tikz}
\tikzset{mynode/.style={fill=white,text=black,font=\tiny,inner sep=1pt}}
\usepackage[toc,page]{appendix}
\addtolength{\topmargin}{-.875in}
\newenvironment{numberlists}[1][3\parindent] %for long numberlist command
 {\begin{list}{}{%
   \leftmargin=#1\relax
   \rightmargin=\leftmargin
   \itemsep=\jot
   \parsep=0pt
   \partopsep=0pt
   \labelsep=0pt}}
 {\end{list}}
\newcommand\numlist[2]{%
  \item[]\makebox[0pt][r]{$#1=\lbrack$}%
  \begingroup
  \begingroup\lccode`~=`,\lowercase{\endgroup\def~}{\mathcomma\penalty0 }%
  \mathcode`,="8000
  \thinmuskip=6mu plus 6mu minus 2mu
  $#2\rbrack$%
  \endgroup
}
\mathchardef\mathcomma=\mathcode`, %end of numberlist command
\setlength{\oddsidemargin}{-1in}   \setlength{\evensidemargin}{-1in}
\addtolength{\oddsidemargin}{25mm}\addtolength{\evensidemargin}{20mm}
\setlength{\marginparwidth}{40pt} \setlength{\marginparsep}{10pt}
\setlength{\topmargin}{-5mm}      \setlength{\headsep}{0.5in}
\setlength{\textheight}{227mm}    \setlength{\textwidth}{165mm}
\renewcommand\floatpagefraction{0.8} %   Default = 0.5
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

\allowdisplaybreaks % allow page breaks
\begin{document}
\begin{titlepage}
\begin{center}
\includegraphics[width=0.70\textwidth]{logo} \\[2cm]

{ \large \bfseries Perfect Triangles : Rational points on Elliptic Curves }\\
Shahrina Ismail \\
\{Candidate's academic degrees\} \\[7cm]
{\em A thesis submitted for the degree of Doctor of Philosophy at\\
The University of Queensland in 2016} \\
School of Mathematics and Physics

\end{center}
\end{titlepage}

\pagenumbering{roman}

\theoremstyle{definition}

\begin{abstract}
here...
\end{abstract}

\tableofcontents

\listoffigures

\listoftables

\newpage
\pagenumbering{arabic}
\onehalfspacing
\chapter{Introduction}
\input{chapters/Introduction}

\onehalfspacing
\chapter{Background and Methodology}\label{chap:2}
\input{chapters/chapter2}


\onehalfspacing
\chapter{Values of $\delta(\mu)$}\label{chap:3}
\input{chapters/chapter3}

\end{document}

答案1

我建议你

  • 将所有前导指令(当然,除了\documentclass指令之外)放在一个单独的文件中,称为(例如)sharina.sty。(注意文件扩展名)。将文件保存在主 tex 文件所在的目录中。

  • 放置单个指令

    \usepackage{sharina}
    

    在你的 tex 文件的序言中。注意:没有文件扩展名。

    经过这一更改,文档序言应该仅包含以下两行:

    \documentclass[12pt,a4paper,twoside]{report}
    \usepackage{sharina}
    

那么,请花一些时间清理并简化文件中包含的说明sharina.sty

相关内容