查看原文
其他

手把手教你制作LaTeX模版

BowerC LaTeX工作室 2024-05-05

对于刚接触 LaTeX 的同学来说,设计一个论文的模板(或者说设计一个自己喜欢的笔记模板)似乎是一件遥不可及的事情,其实不然。今天我们就来看看小白能不能也一步一步的去设计一个自己想要的 LaTeX 模板。

Sci China Tech Sci

我们都知道,我们初步学习 LaTeX 文档类的时候,都会给出这样的代码:

\documentclass{article}
\usepackage[showframe]{fgruler}
\usepackage{lipsum} % 测试文字用
\title{The \LaTeX{} Template for JOR}
\author{Yongxue}
\date{\today}

\begin{document}
\maketitle
\begin{abstract}
  \lipsum[1-1]
\end{abstract}
\lipsum[1-2]
\end{document}
图1

基于图 1,我们以图 1 为起点,一步一步的进行设计(修改),将其做成一个有模有样的形式。为了设计过程中尺寸查看和文字行数等展示,我们引入宏包,并将字体设为 Times 字体,于是在导言区加入如下宏包:

\usepackage[switch,pagewise,running]{lineno}
\linenumbers
\usepackage[showframe]{fgruler}
\usepackage{lipsum}
\usepackage{times}
图2

如图 2,其实和很多小伙伴一样,对于这个见面,初学 LaTeX 的时候我也不注重整个版面,哪个部分叫啥,纸张长宽,大小等我从来都不在意,后面看见很多(封面)等做得很好,看起来给人一种“高大上”的感觉,后面我就看是慢慢关注这些细节,同时,我也将每个部分告诉大家(如图 3 和图 4):

图3
图4

结合图 3 和 4,我们在图 2 基础上进行设置页面格式:

%------------ Page layout -------------------
\textwidth=178truemm
\textheight=228truemm
\topmargin=-27.5pt
\headsep=5truemm
\oddsidemargin=-20pt
\evensidemargin=-20pt
\parindent=0pt
\footskip=0mm
\columnsep 0.7cm
图5

随着导言区设置的内容越来越多,我们将设置的代码规范写成一个 cls 格式的文件,并命名为 ART.cls,其部分代码如下:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{ART}[\sci@filedate, \sci@fileversion]

\LoadClass[twoside]{article}
\RequirePackage{
  amsmath,     amsthm,     amsfonts,     amssymb,     times,
  txfonts,     upgreek,    multicol,     mathrsfs,    pifont,
  amscd,       latexsym,   geometry,     fancyhdr,    graphicx,
  cases,       appendix,   algorithm,    algorithmic, tabularx,
  url,         float,      booktabs,     stfloats,    lipsum,
  ifpdf,       fancyhdr,   lastpage,     placeins,    threeparttable,
  rotfloat,    float,      rotating}


\RequirePackage{xcolor}
\definecolor{Dblue}{RGB}{0,44,91}
\definecolor{Sblue}{RGB}{222,233,247}
\definecolor{Sred}{RGB}{225,41,44}

\RequirePackage[hyperindex=true,colorlinks=true,linkcolor=blue,breaklinks,urlcolor=blue,citecolor=blue]{hyperref}

\usepackage{bm}
\pdfstringdefDisableCommands{
\renewcommand*{\bm}[1]{#1}

}

\urlstyle{same}
\RequirePackage{cuted,flushend}

\usepackage{balance}
\usepackage{titletoc}

%-------------------------- Page layout ------------------------------
\textwidth=178truemm
\textheight=228truemm
\topmargin=-27.5pt
\headsep=5truemm
\oddsidemargin=-20pt
\evensidemargin=-20pt
\parindent=0pt
\footskip=0mm

那么我们在文档类编译的时候,文档类就可以编程如下:

\documentclass{ART}
\begin{document}
 your contents
\end{document}

在 ART 文件中引入宏包:

\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc,fadings,shapes,decorations.markings}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{raster}
\tcbuselibrary{hooks}

设置标题、作者、摘要及关键词格式得到:

图6

同时设置章节标题格式:

\usepackage{titlesec}
\titleformat{\section}[block]{\normalfont\xiaosihao\bfseries}{\thesection}{0.63em}{ }[]
\titleformat{\subsection}[block]{\normalfont\normalsize\bfseries}{\thesubsection}{0.6em}{ }[ ]
\titleformat{\subsubsection}[block]{\normalfont\normalsize\it}{\thesubsubsection}{0.5em}{ }[ ]

\def\sec#1{\vspace{7mm}\noindent{{\xiaosihao\rm\bfseries{#1}}}\vspace{4mm}}
\def\subsec#1{\vspace{5mm}\noindent{\normalsize\bfseries#1}\vspace{2mm}}
\def\subsubsec#1{\vspace{4mm}\noindent{\it #1}\vspace{1mm}}

\newcommand\deareditor{
    {\normalfont\normalsize\bfseries\noindent Dear editor,\par}

}

\newcommand\lettersection[1]{{\it #1}. }
\columnsep 0.7cm
图7

设置参考文献:

\usepackage{cite}
\def\@biblabel#1{#1~}
\renewenvironment{thebibliography}[1]{
    \ifx\@Acknowledgements\@empty\else
    \vskip 3mm\renewcommand{\baselinestretch}{1.08}
 \baselineskip 10pt
    {\bahao\noindent{\it\@Acknowledgements}}
    \fi


    \ifx\@InterestConflict\@empty\else
    {\vskip 3mm\jiuhao\noindent{\textbf{Conflict of interest}\quad\@InterestConflict}}
    \fi


    \ifx\@Supplements\@empty\else
        \vskip 6mm
        {\jiuhao\noindent\textbf{Supporting Information}\vspace{2mm}\\{
        \ifx\@Supplements\blank\else{\@Supplements~ }
\fi
        }}
    \fi

    \section*{%\normalsize\refname
        \@mkboth{\jiuhao\refname}{\jiuhao\refname}
}%
    \vspace{-7mm}
    \list{\@biblabel{\@arabic\c@enumiv}}{
        \settowidth\labelwidth{\@biblabel{#1}}%
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \@openbib@code
        \usecounter{enumiv}%
        \let\p@enumiv\@empty
        \renewcommand\theenumiv{\@arabic\c@enumiv}
    }
    \itemsep 0ex \parskip 0ex
    \footnotesize\sloppy
}
\renewcommand{\UrlFont}{\selectfont}
图8

这样基本上就得到了论文的大致模板,至于更细节的设置,还有待斟酌,由于篇幅、时间及精力因素,分享至此。

最后给出部分代码:

\documentclass{ART}
\begin{document}


\ArticleType{High-speed visual target tracking with mixed rotation invariant
description and skipping searching}


\Year{2023}
\Month{December}
\Vol{62}
\No{1}
\DOI{}
\BeginPage{1}
\EndPage{}
\ReceiveDate{December 09, 2023}
\AcceptDate{October 6, 2023}
\OnlineDate{May 20, 2023}


\title{High-speed visual target tracking with mixed rotation invariant description and skipping searching}
{High-speed visual target tracking with mixed rotation invariant description and skipping searching}


\author[1]{Yongxing YANG}{bsx@zjut.edu.cn}
\author[2]{Jie YANG}{bshaoxian@163.net}
\author[1]{Zhongxing ZHANG}{}


\AuthorMark{Yang Y X}


\AuthorCitation{Yang Y X, Yang J, Zhang Z X, et al}


\address[1]{State Key Laboratory for Superlattices and Microstructures, Institute of Semiconductors, \\
Chinese Academy of Sciences, Beijing {\rm 100083}
, China}
\address[2]{Department of Electrical and Computer Engineering, University of Calgary, Calgary {\rm T2N1N4}, Canada}


\contributions{These authors contributed equally to the work.}%


\abstract{\lipsum[1-2]}

\keywords{target tracking, parallel vision processor, MRID, skipping searching, image processing}


\maketitle

\section{Introduction the most fundamental technologies in computer}
\label{section1}

\lipsum[1-5]

\begin{thebibliography}{999}
\bibitem{1} W. Pauli, \emph{Die allgemeinen Prinzipien der Wellenmechanik} (Springer, Berlin, Heidelberg, 1933).

\bibitem{2} S. Weigert, \href{http://dx.doi.org/10.1103/PhysRevA.45.7688}{Phys. Rev. A} {\bf 45}, 7688 (1992).

\bibitem{3} J. P. Amiet, and S. Weigert, \href{http://dx.doi.org/10.1088/0305-4470/32/15/006}{J. Phys. A-Math. Gen.} {\bf 32}, 2777
 (1999).

\bibitem{4} J. Chen, H. Dawkins, Z. Ji, N. Johnston, D. Kribs, F. Shultz, and B. Zeng, \href{http://dx.doi.org/10.1103/PhysRevA.88.012109}{Phys. Rev. A} {\bf 88}, 012109 (2013).

\bibitem{5} H. Y. Wang, W. Q. Zheng, N. K. Yu, K. R. Li, D. W. Lu, T. Xin, C. Li,  Z. F. Ji, D. Kribs, B. Zeng, X. H. Peng, and J. F. Du, \href{http://dx.doi.org/10.1007/s11433-016-0287-y}{Sci. China-Phys. Mech. Astron.} {\bf 59}, 100313 (2016).

\bibitem{6} T. Heinosaari, L. Mazzarella, and M. M. Wolf, \href{http://dx.doi.org/10.1007/s00220-013-1671-8}{Commun. Math. Phys.} {\bf 318}, 355 (2013).

\bibitem{7} G. Gutoski, and N. Johnston, \href{http://dx.doi.org/10.1063/1.4867625}{J. Math. Phys.} {\bf 55}, 032201 (2014).

\bibitem{8} J. Finkelstein, \href{http://dx.doi.org/10.1103/PhysRevA.70.052107}{Phys. Rev. A} {\bf 70}, 052107 (2004).

\bibitem{9} C. H. Baldwin, I. H. Deutsch, and A. Kalev, \href{http://dx.doi.org/10.1103/PhysRevA.93.052105}{Phys. Rev. A} {\bf 93}, 052105 (2016).

\bibitem{10} C. H. Baldwin, A. Kalev, and I. H. Deutsch, \href{http://dx.doi.org/10.1103/PhysRevA.90.012110}{Phys. Rev. A} {\bf 90}, 012110 (2014).

\bibitem{11} Y. Long, G. R. Feng, J. Pearson, and G. L. Long, \href{http://dx.doi.org/10.1007/s11433-014-5494-1}{Sci. China-Phys. Mech. Astron.} {\bf 57}, 1256 (2014).

\bibitem{12} F. Z. Jin, H. W. Chen, X. Rong, H. Zhou, M. J. Shi, Q. Zhang, C. Y. Ju, Y. F. Cai, S. L. Luo, X. H. Peng, and J. F. Du, \href{http://dx.doi.org/10.1007/s11433-016-5779-7}{Sci. China-Phys. Mech. Astron.} {\bf 59}, 630302 (2016).

\bibitem{13} X. L. Zhen, T. Xin, F. H. Zhang, and G. L. Long, \href{http://dx.doi.org/10.1007/s11433-016-0208-7}{Sci. China-Phys. Mech. Astron.} {\bf 59}, 690312 (2016).

\bibitem{14}  M. A. Nielsen, I, L. Chuang, \emph{Quantum Computation and Quantum Information} (Cambridge University Press, Cambridge, 2010).

\bibitem{15} D. G. Cory, A. F. Fahmy, and T. F. Havel, \href{http://dx.doi.org/10.1073/pnas.94.5.1634}{Proc. Natl. Acad. Sci.} {\bf 94}, 1634 (1997).

\end{thebibliography}

\end{document}

关注我们公众号,学习 LaTeX 无烦恼!

入门资料,免费知识代码:

https://flowus.cn/latex/share/66110e84-b24a-4cd5-b8a7-2ba2afb35a30

精心制作免费视频教程:

https://space.bilibili.com/209746320



继续滑动看下一个
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存