LaTeX的知识

Bisheng Du 杜碧升 

Bisheng Du 杜碧升, PhD, Associate Professor

Department of Management Science & Engineering
School of Business, Ningbo University, Zhejiang, China

Homepage www.dubisheng.com
Email \(\tt {dubisheng@nbu.edu.cn}\)

XeLaTeX的字体问题

XeLaTeX中的XeCJK的字体配置
\usepackage{xeCJK}
\setmainfont{Times New Roman}    % 缺省字体
\setCJKmainfont[BoldFont={Adobe Heiti Std},ItalicFont={Adobe Kaiti Std}]{Adobe Song Std}
\setCJKsansfont{Adobe Heiti Std}
\setCJKmonofont{Adobe Kaiti Std}
\setCJKfamilyfont{song}{Adobe Song Std}
\setCJKfamilyfont{hei}{Adobe Heiti Std}
\setCJKfamilyfont{kai}{Adobe Kaiti Std}
\setCJKfamilyfont{fs}{Adobe Fangsong Std}
%\setCJKfamilyfont{li}{LiSu}
%\setCJKfamilyfont{you}{YouYuan}
%\setCJKfamilyfont{yahei}{Microsoft YaHei}
%\setCJKfamilyfont{xingkai}{STXingkai}
%\setCJKfamilyfont{xinwei}{STXinwei}
%\setCJKfamilyfont{fzyao}{FZYaoTi}
%\setCJKfamilyfont{fzshu}{FZShuTi}
%-------------------------------------------------------------------
\newCJKfontfamily\song{Adobe Song Std}
\newCJKfontfamily\hei{Adobe Heiti Std}
\newCJKfontfamily\kai{Adobe Kaiti Std}
\newCJKfontfamily\fs{Adobe Fangsong Std}
%\newCJKfontfamily\li{LiSu}
%\newCJKfontfamily\you{YouYuan}
%\newCJKfontfamily\yahei{Microsoft YaHei}
%\newCJKfontfamily\xingkai{STXingkai}
%\newCJKfontfamily\xinwei{STXinwei}
%\newCJKfontfamily\fzyao{FZYaoTi}
%\newCJKfontfamily\fzshu{FZShuTi}

\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

简易中文文档配置

中文

\documentclass[14pt,a4paper]{article}
\usepackage{fontspec}
\setmainfont[BoldFont=AdobeHeitiStd-Regular]{AdobeHeitiStd-Regular}
\setsansfont[BoldFont=AdobeHeitiStd-Regular]{AdobeHeitiStd-Regular}
\setmonofont{Times New Roman}
\begin{document}
\title{随手笔记}
\author{作者}
\date{\today}
\maketitle

\end{document}

中文格式问题

日期的两种中文表示
%第一种格式\\
\renewcommand{\today}{\number\year 年 \number\month 月 \number\day 日}
%\today\\
%第二种格式\\
%\renewcommand{\today}{\CJKnumber\year 年 \CJKnumber\month 月 \CJKnumber\day 日}
%\today

Beamer

背景图设置
Global Setting of Background:

In the preamble of your TEX file write the command
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{<file_name>}


Individual Setting of Background:

For a individual setting, write the same line as above just before the \begin{frame} command

of the frame you want to edit, and then wrap it all with braces.
{
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{<file_name>
\begin{frame}
    \titlepage
\end{frame}
}
半透明的背景图
\usepackage{tikz}

\usebackgroundtemplate{%
\tikz\node[opacity=0.13,inner sep=0] {\includegraphics[height=\paperheight,width=\paperwidth,keepaspectratio]{image_name}};}
Beamer的大小比例
%\documentclass[aspectratio=1610]{beamer}
%Sets aspect ratio to 16:10, and frame size to 160mm by 100mm.
%\documentclass[aspectratio=169]{beamer}
%Sets aspect ratio to 16:9, and frame size to 160mm by 90mm.
%\documentclass[aspectratio=149]{beamer}
%Sets aspect ratio to 14:9, and frame size to 140mm by 90mm.
%\documentclass[aspectratio=141]{beamer}
%Sets aspect ratio to 1.41:1, and frame size to 148.5mm by 105mm.
%\documentclass[aspectratio=54]{beamer}
%Sets aspect ratio to 5:4, and frame size to 125mm by 100mm.
%\documentclass[aspectratio=43]{beamer}
%The default aspect ratio and frame size. You need not specify this option.
%\documentclass[aspectratio=32]{beamer}
%Sets aspect ratio to 3:2, and frame size to 135mm by 90mm.
用Tikz在插入的图片上画图(出处)
\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}

\begin{tikzpicture}[nodes={inner sep=0}]
% 插图
\node (a)
  {\includegraphics[width=3cm]{example-image-a}};
\node (b) at (5,0)
  {\includegraphics[width=3cm]{example-image-b}};
% 画图
\draw[->,red,line width=2mm] (a) -- (b);
\draw[<-,blue,line width=2mm] (a) -- ++ (-1,-3);
\draw[green,line width=1mm] (b.center) circle (1.5cm);
\end{tikzpicture}

\end{frame}

\end{document}

参考文献

文中author-year引用文后排序给出(出处)
\documentclass{article}
\usepackage[numbers]{natbib}
\bibliographystyle{plainnat}
\renewcommand\cite[1]{\citeauthor{#1} (\citeyear{#1})}
\begin{document}
\cite{Knuth:BAMSN-1-337}

\bibliography{texbook1}
\end{document}

Inline equations

The conjugate function \(f^\star(y) = \sup_{x \in X}(y^Tx - f(x))\) appears here inline, and is in the variable \(y\). Dollar signs ($) surround the LaTeX equation in the jemdoc source.

Syntax
The sample function $f^\star(y) = \sup_{x \in X}(y^Tx - f(x))$
appears here inline, and is in the variable $y$.

Equations on separate lines

To render an equation on its own line, use backslash-escaped round brackets (\( and \)). For example, the identity

\[ (I + XY)^{-1} = I - X(I + YX)^{-1}Y \]

is typeset on its own line. Yes, round brackets instead of square brackets — this is to avoid a conflict with ordinary square brackets that are escaped to avoid being a link. Sorry.

Syntax
The identity
\(
    (I \+ XY)^{-1} = I - X(I \+ YX)^{-1}Y
\)
is typeset on its own line.

Here, the line breaks (and other whitespace) are ignored. As always, the exact formatting details can be adjusted using CSS.

Notes

  • The baseline is carefully adjusted. The sequences m\(m\)m and y\(y\)y (m$m$m and y$y$y), for example, should be neatly aligned (modulo bad browsers).

  • Definition by cases will work as expected, for example, \(f(x)\), where

\[ f(x) = \left\{ \begin{array}{ll} 3, & x \leq 0 \\ 5, & x > 0. \\ \end{array}\right. \]

Syntax
  \(
  f(x) = \left\{
  \begin{array}{ll}
  3, & x \leq 0 \\
  5, & x > 0. \\
  \end{array}\right.
  \)
  • A random inequality might look like \(3x + 2y^{4k + 6} \geq z\).