支持中文

\documentclass{article}
\usepackage[UTF8]{ctex}
\begin{document}
中文存储系统English
\[E = m c^2\]
\end{document}

上面的代码片段可以支持中文.

pdf支持书签

\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=black]{hyperref}
\begin{document}
	\section{中文测试}
		测试一下中文
		\subsection{进一步测试}
			还是测试
	\section{English test}
		Test English
		
\[E = m c^2\]
\end{document}

绘制架构图

\documentclass[border=10pt]{standalone}
\usepackage{fontawesome5}
\usepackage{tikz}
\usetikzlibrary{fit,arrows,calc,positioning}

\begin{document}

\begin{tikzpicture}[
vbsnode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm},
vamnode/.style={rectangle, draw=blue!60, fill=blue!5, very thick, minimum size=5mm},
clstnode/.style={rectangle, draw=yellow!60, fill=yellow!5, very thick, minimum size=5mm},
]
%Nodes
\node[vbsnode]      (vbs1)                              {vbs1};
\node[vbsnode]      (vbs2)       [right=of vbs1] {vbs2};
\node[vbsnode]      (vbs3)       [right=of vbs2] {vbs3};
\node[vamnode]      (vam1)       [below=of vbs1] {vam1};
\node[vamnode]      (vam2)       [below=of vbs2] {vam2};
\node[vamnode]      (vam3)       [below=of vbs3] {vam3};
\node[clstnode]      (clst1)       [below=of vam1] {clst1};
\node[clstnode]      (clst2)       [below=of vam2] {clst2};
\node[clstnode]      (clst3)       [below=of vam3] {clst3};

%vam1 link
\draw[color=red,->] (vbs1.south) -- (vam1.north);
\draw[color=red,->] (vbs2.south) -- (vam1.north);
\draw[color=red,->] (vbs3.south) -- (vam1.north);

%vam2 link
\draw[color=green,->] (vbs1.south) -- (vam2.north);
\draw[color=green,->] (vbs2.south) -- (vam2.north);
\draw[color=green,->] (vbs3.south) -- (vam2.north);

%vam3 link
\draw[->]  (vbs1.south) -- (vam3.north);
\draw[->] (vbs2.south) -- (vam3.north);
\draw[->] (vbs3.south) -- (vam3.north);

%clst1 link
\draw[color=green!60, ->] (vam1.south) -- (clst1.north);
\draw[color=green!60, ->] (vam2.south) -- (clst1.north);
\draw[color=green!60, ->] (vam3.south) -- (clst1.north);

%clst2 link
\draw[color=blue!60, ->] (vam1.south) -- (clst2.north);
\draw[color=blue!60, ->] (vam2.south) -- (clst2.north);
\draw[color=blue!60, ->] (vam3.south) -- (clst2.north);

%clst2 link
\draw[->] (vam1.south) -- (clst3.north);
\draw[->] (vam2.south) -- (clst3.north);
\draw[->] (vam3.south) -- (clst3.north);

\end{tikzpicture}
\end{document}

页面设置

很多latex模板都将页面边距设置好了,自己不用怎么修改。但有时候也需要自己来设置页边距,查阅了相关资料,发现使用 geometry 宏包可以方便地调整页边距。

\usepackage{geometry}
\geometry{a4paper,scale=0.8}

上面命令设置了纸张为a4 纸,并且版心占页面长度的比例为80%;scale也可以改为ratio,表示版面边距占页面长度的比例。该宏包还可以设置页面的上下左右边距,例如:

\geometry{a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm}

插入代码片段

Code styles and colours
Code formatting with the listing package is highly customisable. Let's see an example

\documentclass{article}
\usepackage[utf8]{inputenc}
 
\usepackage{listings}
\usepackage{color}
 
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
 
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}
 
\lstset{style=mystyle}
 
\begin{document}
The next code will be directly imported from a file
 
\lstinputlisting[language=Octave]{BitXorMatrix.m}
\end{document}

转义字符

下面的这些字符是LATEX 的保留字符:
# $ % ^ & _ { } ~ \

前面加反斜线输出保留字符:
\#   \%   \_    \{  
\}  \~   \&      \$
反斜线 \ 比较特殊: $\backslash$

这下面几个就需要自己用软件编译一下了:
\~{test}   \~{t}{e}{s}{t}
\~{t}\~{e}\~{s}\~{t} \^{} 
\^{test}  \textbackslash
\textcopyright  \newline
\textregistered \newline
$^\circ$C \newline
\pounds \dots
\today  \LaTeX{}
\TeX{} \LaTeXe{}

强制换行: \\

强制空格种类较多,分为以下几种:
句间空格
小写字母后面跟标点符号时,该标点符号之后的空格被认为是句间空格。大写字母后面接标点符号,标点符号后的空格会被误认作是词间空格,此时需要在标点符号之前插入 \@ 命令来强制LaTeX将后面的空格作为句间空格处理。例如: as well as I\@. Hence, ...

词间空格
书写缩写、省略号等情况下,点 . 之后的空格会被误认为是句间空格。使用 \(空格) 代替普通的半角空格可以强制该空格为词间空格。例如: Yamada et al.\ wrote the report.

不可分断空格
用 ~ 代替空格,可使得排版时不会在此处换行。例如 Mr.~Lamport。也可以使用 \mbox命令,例: \mbox{Minoru Sakaguchi}。

圆圈数字

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\circlefont{ipag.ttf}
\usepackage{xunicode-addon}

\begin{document}
{\circlefont\textcircled{323}}
\end{document}

这个文档需要用xelatex来生成pdf.

二维码

\documentclass{article} 
\usepackage{qrcode} 
\begin{document} 
This is a qrcode for Google HK. 
\qrcode{https://www.google.com.hk/} 
\end{document}

多级标题

How to add an extra level of sections with headings below \subsubsection

I have a document which requires many levels of sectioning. I have sections, subsections and subsubsections, but require one more level below that. I can’t change the sections to be parts and move everything up a level, as this document will eventually be included in another document which has parts/chapters already.

I see that the \paragraph command is used for defining the section level below subsubsection, but that doesn’t produce headings in the same way that subsection and subsubsection do. Is there any way to either (1) change the \paragraph command so that it works like subsubsection but just adds another number - ie. 1.2.3.4 or (2) create a \subsubsubsection command to do the same thing?

You can use the titlesec package to change the way \paragraph formats the titles and set the secnumdepth counter to four to obtain numbering for the paragraphs:

\documentclass{article}
\usepackage{titlesec}

\setcounter{secnumdepth}{4}

\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\begin{document}

\section{Test Section}
test
\subsection{Test Subsection}
test
\subsubsection{Test Subsubsection}
test
\paragraph{Test Modified Paragraph}
test

\end{document}

enter image description here

If you want to define a new sectioning command, you can take a look at Defining custom sectioning commands.

If you want to define a fresh new sectional unit below \subsubsection, but above \paragraph, then you will have to do considerably more work: a new counter has to be created and its representation has to be appropriately defined; the sectional units \paragraph and \subparagraph will also have to be redefined, as well as they corresponding \l@... commands (controlling how the will be typeset in the ToC if the tocdepth value is increased); also, the toclevel (for eventual bookmarks) will have to be considered.

Here’s an example showing how to obtain this new sectional unit giving you now the option to use \part, \section, \subsection, \subsubsection, \subsubsubsection, \paragraph, and \subparagraph:

\documentclass{article}
\usepackage{titlesec}
\usepackage{hyperref}

\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

\begin{document}

\tableofcontents
\section{Test Section}
test
\subsection{Test Subsection}
test
\subsubsection{Test Subsubsection}
test
\subsubsubsection{Test Subsubsubsection}
test
\paragraph{Test Paragraph}
test
\subparagraph{Test Subparagraph}
test

\end{document}

enter image description here