LaTex

    软件使用     LaTex

高亮

  1. latex 中文 高亮 并可自动换行的方法? - 知乎 (zhihu.com)
1
2
3
4
5
6
7
8
9
\documentclass[UTF8]{ctexart} 
% 关键代码
\usepackage{cjkhl}
\usepackage{color} \
definecolor{lightblue}{rgb}{.8,.8,1}
\begin{document}
\cjkhl{yellow}{其实他也不是随机生成段落,而是从公元前45年的古典拉丁文学著作中截取150个段落中挑选段落。因为这部著作的第一段的前两个词为:Lorem ipsum,因此称为 lipsum。}
\cjkhl{lightblue}{其实他也不是随机生成段落,而是从公元前45年的古典拉丁文学著作中截取150个段落中挑选段落。因为这部著作的第一段的前两个词为:Lorem ipsum,因此称为 lipsum。}
\end{document}

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
%%cjkhl.sty

% derived from an answer to the question
% http://tex.stackexchange.com/questions/75019/is-there-any-resolution-for-highlighting-text-in-cjk


% May be distributed under MIT or LPPL licences.

% David Carlisle

\ProvidesPackage{cjkhl}[2012/08/04 v0.01 Highlighting in CJK documents (DPC)]

\newcommand*{\cjkhl}[2]{{\def\xcjklhcolorbox{\colorbox{#1}}\xcjkhl#2\relax}}

\makeatletter

%look ahhead for the next character
\def\xcjkhl{\futurelet\tmp\xxcjkhl}

%helper macro to make leaders with a highlight box.
\def\xcjkhlleaders{\leavevmode\leaders\hbox{%
\fboxsep\z@\xcjklhcolorbox{\strut\kern.1pt%
\ifx\cjkhlbleed\@empty\else\kern\cjkhlbleed\fi\relax}%
\ifx\cjkhlbleed\@empty\else\kern-\cjkhlbleed\fi\relax}}

% leaders with a 1pt of stretch/shrink to put before or after punctuation
\def\@@yhlstretch{\leavevmode\xcjkhlleaders\hskip\z@\@plus.1em \@minus.1em }

\def\@chkhlpar#1\fi\fi#2{\par\noindent\xcjkhl}

\def\@cjkhl@beforeafter#1{%
\ifx\tmp#1%
\@@yhlstretch
\let\@chkhlstretch\@@yhlstretch
\let\cjkhlpenalty\@highpenalty
\fi}

\def\@cjkhl@after#1{%
\ifx\tmp#1%
\let\@chkhlstretch\@@yhlstretch
\let\cjkhlpenalty\@highpenalty
\fi}

\def\@cjkhl@before#1{%
\ifx\tmp#1%
\@@yhlstretch
\let\cjkhlpenalty\@highpenalty
\fi}

\def\xxcjkhl{%
%look for a \par (from \obeylines)
\ifx\tmp\par\expandafter\@chkhlpar\fi
%look for a \relax to finish
\ifx\tmp\relax
\else
%by default do no stretch leaders after the character
\let\@chkhlstretch\relax
\let\cjkhlpenalty\z@
%these stretch before and after
\@cjkhl@beforeafter%
\@cjkhl@beforeafter%
% these stretch after
\@cjkhl@after%
\@cjkhl@after%
\@cjkhl@after%
\@cjkhl@after%
\@cjkhl@after%
%these stretch before
\@cjkhl@before%
\@cjkhl@before%
\@cjkhl@before%
% look for a space
\ifx\tmp\@sptoken
\xxxcjkhlsp
\else
%default case stick the current character in a box
\xxxcjkhl
\fi\fi}

%make a highlight leaders stretch/shrink as much as a normal word space.
\def\xxxcjkhlsp#1\fi\fi#2{%
\fi\fi
\xcjkhlleaders\hskip \fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font\relax
\xcjkhl#2}

%get out of a double \if test
\def\xxxcjkhl\fi\fi{%
\fi\fi
\@chkhl}

%The simple case box the current character and start looking for the next.
% bleed slightly on the right to avoid gaps showing
\let\cjkhlbleed\@empty

\def\@chkhl#1{{%
\fboxsep\z@
\leavevmode\penalty\cjkhlpenalty
\xcjklhcolorbox{%
\strut#1\ifx\cjkhlbleed\@empty\else\kern\cjkhlbleed\fi}}%
\ifx\cjkhlbleed\@empty\else\kern-\cjkhlbleed\fi\relax
\@chkhlstretch
\xcjkhl}%

超链接

  1. latex 引用 section [转]_weixin_34405332 的博客-CSDN 博客

beamer

  1. beamer模板设计(八)beamer中颜色的设置和继承关系 - 知乎 (zhihu.com)
  2. beamer模板设计(五)headline中的色彩和字体 - 知乎 (zhihu.com)

2022/11/17

  1. LaTeX 笔记模板整理 - 知乎 (zhihu.com)
  2. 【已解决】【LaTeX】acmart模板中使用xcolor出错:Option clash for package xcolor._宇内虹游的博客-CSDN博客
  3. 科学网—LaTeX Error: Not in outer par mode. - 朱小栋的博文 (sciencenet.cn)

常用的代码片段

1
2
3
4
\begin{enumerate}[i)]
\item...
\item...
\end{enumerate}
1
\url{https://github.com/davidgao666/HedaBachelorTemplate}
1
2
3
4
5
\begin{description}
\item[Step 1] ...
\item[Step 2] ...
\item[Step 3] ...
\end{description}

插入公式

插入多行公式时,空格问题

第一个正确,第二个不对,因此在 插入公式时,就不要有空格 ,避免不必要的麻烦。

1
2
3
4
5
6
7
8
\begin{equation}
\left\{ \begin{array}{l}
r_k=\sum_{j=1}^p{w_{kj}x_j\text{,}}\\
v_k=r_k-\theta _k,\\
y_k=\varPhi \left( v_k \right),\\
\end{array} \right.
\end{equation}

1
2
3
4
5
6
7
8
9
\begin{equation}

\left\{ \begin{array}{l}
r_k=\sum_{j=1}^p{w_{kj}x_j\text{,}}\\
v_k=r_k-\theta _k,\\
y_k=\varPhi \left( v_k \right),\\
\end{array} \right.

\end{equation

页眉

1
2
3
4
5
6
7
8
9
10
11
12
13
只给每一章首页加页眉

\makeatletter
\let\ps@plain\ps@empty
\makeatother
\fancypagestyle{plain}{%
\fancyhf{} %
\fancyhead[LO,RE]{...} %
\fancyhead[RO,LE]{...} %
\fancyfoot[C]{...} %
\renewcommand{\headrulewidth}{0.4pt} %
\renewcommand{\footrulewidth}{0.4pt} %
}
page PV:  ・  site PV:  ・  site UV: