关于Latex 最近由于需要自己重新制作一份模板,所以随机入门了Latex,摒弃了十分优秀的Markdown,最关键的原因主要有两个:
Latex 可以方便的生成目录和页码 论文一般都用Latex排版(当然也有用Word) 由于Markdown确实只能做一些比较随意的东西,而且想做好某些东西确实会很难,不过typora里可以编写一些html代码,确实如果只是在电脑上阅览的话, export成html格式是十分舒服的。
自己没有像队友那样系统的学习,临时想用Latex,所以临时配置,临时写,平常习惯了在Markdown里面书写数学公式,所以后期写内容的时候十分快捷。
前期的时间主要花在配置环境与寻找可用的模板。
先讲述一下我的配置,我刚开始的时候安装了CTex,后来这个东西十分鸡肋,而且我用起来也十分不爽,不过这个软件大概是帮我把我需要的环境都配好了。后来我寻找到了一款比较好用的编辑器: TexStudio
在Tools里command可以选择编译用的exe,有Latex,XeLatex, pdfLatex, 不同的选项可以使用的东西不同。
我选择的pdfLaTex(好像是默认的),编译后可以生成pdf,可以直接使用。每次编译后可以在右侧直接预览。
我没有系统的学习,只是用啥学啥,先讲一下我的ACM模板的配置:
常用宏包,环境: 1 2 3 4 5 6 7 8 9 10 11 12 13 %==============================常用宏包、环境==============================% \documentclass[a4paper,UTF8]{article} %A4大小,支持放入utf8字符 \usepackage{ctex} % pdftex 用的中文包 % \usepackage{xeCJK} % Xelatex 中文 \usepackage{amsmath, amsthm} % 数学需要的 \usepackage{listings, xcolor} %插入代码 \usepackage{geometry} % 设置页边距 \usepackage{graphicx} \usepackage{enumerate} \usepackage{fancyhdr} % 自定义页眉页脚 \geometry{left=3cm,right=1cm,top=2cm,bottom=0.5cm} % 页边距 \setlength{\columnsep}{30pt} %两栏之间的间距大小 %==============================常用宏包、环境==============================%
页眉、页脚、代码格式设置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 %==============================页眉、页脚、代码格式设置==============================% % 页眉、页脚设置 \pagestyle{fancy} % \lhead{CUMTB} \lhead{ 苏州大学 } \chead{} % \rhead{Page \thepage} \rhead{ 第 \thepage 页} \lfoot{} \cfoot{} \rfoot{} % 代码格式设置 \lstset{ language = c++, numbers = left, numberstyle = \tiny, breaklines = true, captionpos = b, tabsize = 4, frame = single, columns = fullflexible, commentstyle = \color[RGB]{0,128,0}, keywordstyle = \color[RGB]{0,0,255}, basicstyle = \small\ttfamily, escapeinside= ``, stringstyle = \color[RGB]{148,0,209}\ttfamily, rulesepcolor = \color{red!20!green!20!blue!20}, showstringspaces = false, } %==============================页眉、页脚、代码格式设置==============================%
除此之外,有用过其写一些作业的格式,下面贴出:
sbc-template.sty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 % LaTeX definitions for SBC 2001 style % % Created by Jomi Hubner & Rafael Bordini, june 2001 % updated march 2005 \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{sbc-template}[2001/06/09] % margem sup 3.5 cm: h� 1,5 cm para header, + 2 cm para top % margem inf 2.5 cm: h� 1,5 cm para foot, + 1 cm para bottom % margem esq/dir 3 cm \RequirePackage[a4paper,top=3.5cm,left=3cm,right=3cm,bottom=2.5cm]{geometry} \parindent 1.27cm \parskip 6pt \flushbottom % captions \RequirePackage[bf,sf,footnotesize,indent]{caption2} \setlength{\captionmargin}{0.8cm} \renewcommand{\captionfont}{\sffamily\footnotesize\bfseries} \renewcommand{\captionlabeldelim}{.} % font \RequirePackage{times} \renewcommand{\normalsize}{\@setfontsize\normalsize\@xiipt\@xivpt} \newcommand{\XIIIPT}{\@setfontsize\xiiipt{13}{17}} \newcommand{\XVIPT}{\@setfontsize\xvipt{16}{20}} % new commands \newcounter{instn} \setcounter{instn}{1} \newcommand{\instnum}{\arabic{instn}} \newcommand{\inst}[1]{\ensuremath{^{#1}}} \newcommand{\nextinstitute}{\\\mbox{}\\[-6pt] \addtocounter{instn}{1}\inst{\instnum}} \newcommand{\email}[1]{\\\mbox{}\\[-6pt]\footnotesize\texttt{#1}} \renewcommand{\and}{, } % to avoid [...] in the bibliography % \item[] instead of \item[\@biblabel{#1}\hfill] \def\@lbibitem[#1]#2{\item[]\if@filesw {\let\protect\noexpand \immediate \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces} \renewenvironment{thebibliography}[1] {\section*{\refname \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}% \list{\@biblabel{\@arabic\c@enumiv}}% {\settowidth\labelwidth{\@biblabel{#1}}% \leftmargin\labelwidth \advance\leftmargin\labelsep %% changed! \itemindent -\leftmargin \itemsep 6pt %%%%%%%%%%% \@openbib@code \usecounter{enumiv}% \let\p@enumiv\@empty \renewcommand\theenumiv{\@arabic\c@enumiv}}% \sloppy \clubpenalty4000 \@clubpenalty \clubpenalty \widowpenalty4000% \sfcode`\.\@m} {\def\@noitemerr {\@latex@warning{Empty `thebibliography' environment}}% \endlist} % itens \setlength\leftmargini {1.27cm} \setlength\leftmargin {\leftmargini} \setlength\leftmarginii {\leftmargini} \setlength\leftmarginiii {\leftmargini} \setlength\leftmarginiv {\leftmargini} \setlength \labelsep {.5em} \setlength \labelwidth {\leftmargini} \addtolength\labelwidth {-\labelsep} \def\@listI{\leftmargin\leftmargini \parsep 0\p@ \@plus1\p@ \@minus\p@ \topsep 0\p@ \@plus2\p@ \@minus4\p@ \itemsep0\p@} \let\@listi\@listI \@listi \def\@listii {\leftmargin\leftmarginii \labelwidth\leftmarginii \advance\labelwidth-\labelsep \topsep 0\p@ \@plus2\p@ \@minus\p@} \def\@listiii{\leftmargin\leftmarginiii \labelwidth\leftmarginiii \advance\labelwidth-\labelsep \topsep 0\p@ \@plus\p@\@minus\p@ \parsep \z@ \partopsep \p@ \@plus\z@ \@minus\p@} % sections \renewcommand\section{\@startsection{section}{1}{\z@}% {-6\p@ \@plus -4\p@ \@minus -4\p@}% {0\p@ \@plus 4\p@ \@minus 4\p@}% {\normalfont\XIIIPT\bfseries\boldmath \rightskip=\z@ \@plus 8em\pretolerance=10000 }} \renewcommand\subsection{\@startsection{subsection}{2}{\z@}% {-6\p@ \@plus -4\p@ \@minus -4\p@}% {0\p@ \@plus 4\p@ \@minus 4\p@}% {\normalfont\normalsize\bfseries\boldmath \rightskip=\z@ \@plus 8em\pretolerance=10000 }} %\renewcommand{\thesection}{\arabic{section}.} %\renewcommand{\thesubsection}{\thesection\arabic{subsection}.} %\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.} \RequirePackage{titlesec} \titlelabel{\thetitle.\hspace{1ex}} % first page \pagestyle{empty} \newcommand{\authortag}[1]{$^{#1}$} \def\address#1{\gdef\@address{#1}} \def\@maketitle{\newpage %\null % isso dava um espaco extra antes do title \begin{center} %\vglue -6pt % \vspace*{12pt} \vspace*{-.7cm} {\XVIPT\bf\@title\par} \vglue 6pt plus 3pt minus 3pt {\normalsize \textbf{\begin{tabular}[t]{c}\@author\end{tabular}}\par} \vglue 6pt plus 3pt minus 3pt {} \vglue 6pt plus 3pt minus 3pt \end{center}\par } \let\maketitleOLD\maketitle \renewcommand{\maketitle}{\maketitleOLD\thispagestyle{empty}} \renewenvironment{abstract}{% \list{}{\advance\topsep by6pt\relax%\small \leftmargin=0.8cm \labelwidth=\z@ \listparindent=\z@ \itemindent\listparindent \rightmargin\leftmargin}\item[\hskip\labelsep \bfseries\itshape Abstract.]\itshape}% {\endlist} \newenvironment{resumo}{% \list{}{\advance\topsep by6pt\relax%\small \leftmargin=0.8cm \labelwidth=\z@ \listparindent=\z@ \itemindent\listparindent \rightmargin\leftmargin}\item[\hskip\labelsep \bfseries\itshape Resumo.]\itshape}% {\endlist}
主文件sbc-template.tex格式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 \documentclass[13pt,UTF8]{article} \usepackage{ctex} \usepackage{sbc-template} \usepackage{graphicx,url} \usepackage{cite} %\usepackage[latin1]{inputenc} \usepackage[utf8]{inputenc} % UTF-8 encoding is recommended by ShareLaTex \usepackage{verbatim} \usepackage{listings} \usepackage{xcolor} \definecolor{verde}{rgb}{0,0.5,0} %para customizar o código (ver https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings) \lstset{language=C, %defina a linguagem usada no trabalho belowcaptionskip=1\baselineskip, breaklines=true, frame=false, xleftmargin=\parindent, showstringspaces=false, basicstyle=\footnotesize\ttfamily, keywordstyle=\bfseries\color{green!40!black}, commentstyle=\itshape\color{purple!40!black}, identifierstyle=\color{blue}, stringstyle=\color{orange}, numbers=left, } \sloppy \title{Title} \author{Huchi \\ Soochow University \email{1627406066@stu.suda.edu.cn}} \begin{document} \maketitle \begin{resumo} resumo \end{resumo} \begin{abstract} abstract \end{abstract} \section{Attention} \section{Solution about the first problem} \label{sec:firstpage} \newpage \section{Soution about the second problem} \bibliographystyle{sbc} \begin{thebibliography}{1} \bibitem{lamport94} NP-Completeness of Independent Set, Data Structures and Algorithms, K. Viswanathan Iyer \end{thebibliography} \end{document}