基本工具
市面上有不少LaTeX专用的写作工具,我自己尝试了tekmaker,配置起来麻烦,功能也不强大。最后还是用 Visual Studio Code 这个万能编辑器,功能还是不错的。记录一下配置环境的过程。
LaTeX Workshop
在VS Code中搜索LaTeX Workshop
插件,安装即可。
用了一下,功能还是比较多,代码提示和补全都有,还可以实时预览PDF。
发布中文的时候要修改一下发布工具,不然是无法发布成功,配置如下。
[!NOTE]
编译中文LaTeK文件时,需要用xelatex工具,需要在settings.json中找到
latex-workshop.latex.recipe.default
,然后将值设置为latexmk (xelatex)
。或者直接添加下方代码也可:
"latex-workshop.latex.recipe.default": "latexmk (xelatex)"
Latex 模板
用的是Elegantbook,看起来还可以,再稍微定制一下,还是比较容易得到自己满意的外观的。
每章的内容提要:
\begin{introduction}
\item Definition of Theorem
\item Ask for help
\item Optimization Problem
\item Property of Cauchy Series
\item Angle of Corner
\end{introduction}
每章的作业练习
\begin{problemset}
\item exercise 1
\item exercise 2
\item exercise 3
\end{problemset}
LateX 快速入门
命令 | 描述 |
---|---|
\ | 命令以反斜杠开头。例如:\documentclass |
{ } | 命令参数用大括号括起来。例如:\documentclass{class} |
[ ] | 可选参数用方括号括起来,放在命令参数之前。例如:\documentclass[opt,opt,…]{class} |
快速入门
在编辑器中首先输入下方代码,生成第一个PDF文档
\documentclass[12pt]{article}
\usepackage{palatino,url}
\begin{document}
\section*{My first document}
This is a short example of a \LaTeX\ document written
\today. It shows a few simple features of automated
typesetting, including
\begin{itemize}
\item setting the default font size to 12pt
\item specifying an article type for formatting
\item using the Palatino typeface
\item adding special formatting for URIs
\item formatting a heading in section style
\item using the \LaTeX\ logo
\item generating today's date
\item formatting a list of items
\item centering and italicizing
\item autonumbering the pages
\end{itemize}
\subsection*{More information}
This example was taken from Formatting Information,
which you can download from
\url{http://www.ctan.org/tex-archive/info/beginlatex/}
and use as a teach-yourself guide.
\begin{center}
\textit{Some text to close the document}
\end{center}
\end{document}
示例root文件
% Define the document class
\documentclass[a4paper,12pt,draft,twoside]{book}
%Reference the stylesheet
\usepackage{styles/mystyles}
% Begin the document scope
\begin{document}
% Insert the title page and table of contents
\frontmatter
\include{tex/title}
\tableofcontents
\mainmatter
\include{tex/preface}
\include{tex/intro}
\include{tex/chap01}
\include{tex/chap02}
\include{tex/summary}
\backmatter
\end{document}
文档要素
Document classes
Usage: \documentclass[opt,opt]{class}
\documentclass{class}
book %Default is two-sided.
report %No \part divisions.
article %No \part or \chapter divisions.
letter %Letter (?).
slides %Large sans-serif font.
Use \begin{document}
to start contents and \end{document}
to end the document.
Common documentclass options
% 10pt/11pt/12pt Font size.
% letterpaper/a4paper Paper size.
% twocolumn Use two columns.
% twoside Set margins for two-sided.
% landscape Landscape orientation. Must use dvips-t landscape.
% draft Double-space lines.
Title
\author{text} % Author of document.
\title{text} % Title of document.
\date{text} %Date.
These commands go before \begin{document}
. The declaration \maketitle
goes at the top of the document.
Document structure
\part{title}
\chapter{title}
\section{title}
\subsubsection{title}
\paragraph{title}
\subparagraph{title}
\subsection{title}
Text environments
\begin{comment} % Comment (not printed). Requires verbatim package.
\begin{quote} % Indented quotation block.
\begin{quotation} %Like quote with indented paragraphs.
\begin{verse} %Quotation block for verse.