LaTeX总结-2023年9月8日

1. LaTeX总结

文章目录


/*

  • File: LaTeX总结.md
  • Project: LaTeX软件使用总结
  • File Created: Wednesday, 10th November 2021 7:29:23 pm
  • Author: Hanlin Gu (hg_fine_codes@163.com)


  • copyright © 2021 - 2023 Hanlin Gu
    */

1.1. 定义作者,通讯作者,地址,宏包

1.1.1. Example 1

Reference

latex 定义作者,通讯作者,联系地址宏包,package,authblk

宏包使用:authblk

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{authblk}

\title{More than one Author with different Affiliations}
\author[a]{Author A}
\author[a]{Author B}
\author[a]{Author C \thanks{Corresponding author: email@mail.com}}
\author[b]{Author D}
\author[b]{Author E}
\affil[a]{Department of Computer Science, \LaTeX\ University}
\affil[b]{Department of Mechanical Engineering, \LaTeX\ University}

% 使用 \thanks 定义通讯作者

\renewcommand*{\Affilfont}{\small\it} % 修改机构名称的字体与大小
\renewcommand\Authands{ and } % 去掉 and 前的逗号
\date{} % 去掉日期

\begin{document}
  \maketitle
\end{document}

效果显示:
Fig1

1.1.2. Example 2

\documentclass{article}
\usepackage{hyperref}
\newcommand{\footremember}[2]{%
    \footnote{#2}
    \newcounter{#1}
    \setcounter{#1}{\value{footnote}}%
}
\newcommand{\footrecall}[1]{%
    \footnotemark[\value{#1}]%
} 
\title{How to bowl properly}
\author{%
  The Dude\footremember{alley}{Holly Star Lanes Bowling Alley}%
  \and Walter Sobchak\footremember{trailer}{Probably in a trailer park}%
  \and Jesus Quintana\footrecall{alley} \footnote{Mexico?}%
  \and Uli Kunkel\footrecall{trailer} \footnote{Germany?}%
  }
\date{}
\begin{document}
\maketitle
The whole example is taken from \href{http://anthony.liekens.net/index.php/LaTeX/MultipleFootnoteReferences}{Anthony Liekens}\ldots
\end{document}

效果显示:

Fig2

1.1.3. 特殊符号——作者标注注

符号LaTex符号LaTex
∗ \ast \ast ⋆ \star \star
† \dagger \dagger ‡ \ddagger \ddagger

1.2. 调整字体

1.2.1. 数学模式下使用正体

知乎:LaTeX系列笔记(3)-数学运算符 Math Operator

https://zhuanlan.zhihu.com/p/137969798

(1)直接调用罗马体

\mathrm{d}

直接使用罗马体的问题是不能加上标、前后间距不好调。

(2)用mathopmathrm,使它成为一个数学运算符(Math Operator)

\mathop{\mathrm{d}}

可以在导言区定义一个命令

\newcommand*{\dif}{\mathop{}\!\mathrm{d}}

(3)利用amsmath包的\operatorname实现(调用amsopn

\usepackage{amsmath}
$\operatorname{arccot}$  % 不能把上下标放在符号的正上方或正下方
$\operatorname*{max}$  % 可以把上下标放在符号的正上方或正下方

\operatorname的具体实现比第 2 个办法略微复杂一些,可以处理一些特殊的情况(主要是处理函数名里面有特殊字符),还可以控制上下标能否放在正上方或正下方。大多数情况和上一个方法是是完全等效的。

(4)推荐:使用\operatorname打包成的\DeclareMathOperator

\usepackage{amsmath}

\DeclareMathOperator{\arccot}{arccot}  % 不能把上下标放在符号的正上方或正下方
\DeclareMathOperator*{\Max}{max}   % 可以把上下标放在符号的正上方或正下方

可以调用

\arccot^2     % 不能用\arccot\limits^2
\Max_u, \Max\limits_u  % 都可以使用

如果经常使用\Max\limits_u,一个方便的方法是

\usepackage{amsmath}

\DeclareMathOperator*{\MaxTemp}{max}
\newcommand*{\Max}[1]{\MaxTemp\limits_{#1}}

\begin{document}
\Max{u}  % 也就是\Max\limits_u
\end{document}

也可以用第二个或第三个方法

\newcommand*{\Max}[1]{\mathop{\mathrm{max}}\limits_{#1}}
或者是
\newcommand*{\Max}[1]{\operatorname*{max}\limits_{#1}}

\begin{document}
\Max{u}
\end{documnet}

(5)更换\Re\Im的符号为Re和Im

\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}

1.2.2. LaTeX内使用中文

使用中文撰写 L a T e X LaTeX LaTeX文件需要注意以下问题:

确认TeX发行版是否支持中文,如CTeXTeX LiveMiKTeX等;

需要在导言区中使用\usepackage{xeCJK}\usepackage{ctex}加载中文宏包;
相关编辑器需要设置为UTF-8编码格式;
纯英文TeX文档可能会出现中文乱码问题,可以使用UTF-8编码格式或GBK编码格式。
下面是一个简单的中文示例:

\documentclass{article}
\usepackage{xeCJK}   %或者使用\usepackage{ctex}
\setCJKmainfont{SimSun}   %设置为系统中的宋体字体,也可以换成其他常见中文字体

\begin{document}
这是一段中文。 %请确保编辑器编码格式正确,否则会出现中文乱码

数学公式: $E=mc^2$。

\end{document}

Fig9

注意:在编译时,需要使用xelatex将其编译成 PDF。

1.2.3. 正文文字

功能显示 L a T e X LaTeX LaTeX
加粗 加粗字体 \textbf{加粗字体} 加粗字体\textbf{加粗字体}
斜体 斜体字体 \textit{斜体字体} 斜体字体\textit{斜体字体}
加粗并斜体 加粗与斜体 \textbf{\textit{加粗与斜体}} 加粗与斜体\textbf{\textit{加粗与斜体}}

1.3. 常用符号及字母

List of LaTeX mathematical symbols - OeisWiki

PDF文件The Comprehensive LaTeX Symbol List (ctan.org)

1.3.1. 符号

1.3.1.1. 关系符号
名称符号 L a T e X LaTeX LaTeX名称符号 L a T e X LaTeX LaTeX
约等于
is approximately
≈ \approx \approx近似于
is similar to
∼ \sim \sim
正比于
is proportional to
∝ \propto \propto不等于
is not equal to
≠ \ne =\ne
真子集
is a proper subset of
⊂ \subset \subset子集
is a subset of
⊆ \subseteq \subseteq
is a proper superset of ⊃ \supset \supsetis a superset of ⊇ \supseteq \supseteq
非子集
is not a proper subset of
⊄ \not\subset \not\subset差集
set difference
∖ \setminus \setminus
交集
intersect
∩ \cap \cap并集
union
∪ \cup \cup
平行
is parallel with
∥ \parallel \parallel元素
is member of
∈ \in \in
1.3.1.2. 运算符号
名称符号 L a T e X LaTeX LaTeX名称符号 L a T e X LaTeX LaTeX
加减与减加
plus or minus
minus or plus
± \pm ±
∓ \mp
\pm \mp乘法 × \times ×\times
点乘
dot product
⋅ \cdot \cdot张量乘积
tensor product
⊗ \otimes \otimes
除法 ÷ \div ÷\div度数 degree θ ∘ \theta^{\circ} θ\theta^{\circ}
模 Norm ∥ v ∥ \lVert \boldsymbol{v} \rVert v\lVert \boldsymbol{v} \rVert
1.3.1.3. 箭头
符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX
→ \to \to → \rightarrow \rightarrow
⇒ \Rightarrow \Rightarrow ⟹ \Longrightarrow \Longrightarrow
↔ \leftrightarrow \leftrightarrow ⇔ \Leftrightarrow \Leftrightarrow
   ⟺    \iff \iff
1.3.1.4. 特殊符号——作者标注
符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX
∗ \ast \ast ⋆ \star \star
† \dagger \dagger ‡ \ddagger \ddagger
1.3.1.5. 下划线

在文章中输入单个下划线可使用: \textunderscore

输入长下划线可使用:

(1)\rule{4cm}{0.4pt} 创建一个4cm长,0.4 points厚的下划线;

\documentclass{article}

\begin{document}
This is a long underscore: \rule{4cm}{0.4pt}
\end{document}

(2)使用ulem宏包中的\uline{\hspace{4cm}} 创建了一个4cm长的下划线。

\documentclass{article}
\usepackage{ulem}

\begin{document}
This is a long underscore: \uline{\hspace{4cm}}
\end{document}

1.3.2. 常用字母

常用字母列表:

符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX
φ \varphi φ\varphi ϕ \phi ϕ\phi
σ \sigma σ\sigma τ \tau τ\tau
ξ \xi ξ\xi ϵ \epsilon ϵ\epsilon
ρ \rho ρ\rho η \eta η\eta
α \alpha α\alpha β \beta β\beta
γ \gamma γ\gamma θ \theta θ\theta
1.3.2.1. 花体字母

参考:latex如何输出花体字母
https://blog.csdn.net/weixin_43748786/article/details/100851307

引用包

\usepackage{amsmath, amsthm, amssymb}
\usepackage{mathrsfs}

命令语句

$\mathbb{R}$

$\mathcal{R}$

$\mathscr{R}$

显示效果

符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX
R \mathbb{R} R\mathbb{R} R \mathcal{R} R\mathcal{R} R \mathscr{R} R\mathscr{R}

1.3.3. 字母或数字上下增加内容

1.3.3.1. 字母或者数字上方符号
符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX符号 L a T e X LaTeX LaTeX
a ^ \hat{a} a^\hat{a} a ^ \widehat{a} a \widehat{a} a ˇ \check{a} aˇ\check{a}
a ~ \tilde{a} a~\tilde{a} a ~ \widetilde{a} a \widetilde{a}
a ˙ \dot{a} a˙\dot{a} a ¨ \ddot{a} a¨\ddot{a}
a ˉ \bar{a} aˉ\bar{a} a ‾ \overline{a} a\overline{a} a ⃗ \vec{a} a \vec{a}
a ˊ \acute{a} aˊ\acute{a} a ˋ \grave{a} aˋ\grave{a} a ˘ \breve{a} a˘\breve{a}
1.3.3.2. 字母或者数字上下增加内容

使用\substack{},在字母 σ \sigma σ下方加点,\\ 后方为字母下方的符号

符号LaTex
σ ˙ \substack{\sigma \\\\{\dot{}}} σ˙\substack{\sigma \\{\dot{}}}

1.3.4. 求和、积分、极限

1.3.4.1. 求和
符号LaTex符号LaTex
∑ i = 1 N \sum_{i=1}^{N} i=1N\sum_{i=1}^{N} ∑ i = 1 N \sum\limits_{i=1}^{N} i=1N\sum\limits_{i=1}^{N}
1.3.4.2. 积分
符号LaTex符号LaTex
∫ \int \int ∫ 1 2 x d x \int_1^{2} x \mathrm{d} x 12xdx\int_1^{2} x \mathrm{d} x
∫ 1 10 \int_{1}^{10} 110\int_{1}^{10} ∫ 1 10 \int\limits_{1}^{10} 110\int\limits_{1}^{10}
1.3.4.2.1. 定积分

∣ ∣ a 0 a \left.\vphantom{\Big|}\right|_{a_0}^{a} a0a: \left.\vaphantom{\Big|}\right|_{a_0}^{a}

  • 示例1

∫ a 0 a x d x = 1 2 x 2 ∣ ∣ a 0 a = 1 2 ( a 2 − a 0 2 ) \int \limits_{a_0}^{a}x \mathrm{d}x=\dfrac{1}{2}x^2 \left.\vphantom{\Big|}\right|_{a_0}^{a}=\dfrac{1}{2}(a^2-{a_0}^2) a0axdx=21x2 a0a=21(a2a02)

\int \limits_{a_0}^{a}x \mathrm{d}x
=\dfrac{1}{2}x^2 \left.\vphantom{\Big|}\right|_{a_0}^{a}
=\dfrac{1}{2}(a^2-{a_0}^2)
  • 示例2

∫ a 0 a x d x = 1 2 x 2 ∣ ∣ a 0 a = 1 2 ( a 2 − a 0 2 ) \begin{aligned} \int \limits_{a_0}^{a} x \mathrm{d}x &= \dfrac{1}{2} x^2 \left.\vphantom{\Big|}\right|_{a_0}^{a}\\\\ &= \dfrac{1}{2}(a^2 - a_0^2) \end{aligned} a0axdx=21x2 a0a=21(a2a02)

\begin{aligned}
\int \limits_{a_0}^{a} x \mathrm{d}x 
&= \dfrac{1}{2} x^2 \left.\vphantom{\Big|}\right|_{a_0}^{a}\\
&= \dfrac{1}{2}(a^2 - a_0^2)
\end{aligned}
1.3.4.3. 极限
符号LaTex符号LaTex
lim ⁡ n → ∞ \lim_{n \to \infty} limn\lim_{n \to \infty} lim ⁡ n → ∞ \lim\limits_{n \to \infty} nlim\lim\limits_{n \to \infty}

上、下极限

符号LaTex符号LaTex
l i m ‾ ⁡ n → ∞ \varlimsup_{n \to \infty} limn\varlimsup_{n \to \infty} l i m ‾ ⁡ n → ∞ \varliminf_{n \to \infty} limn\varliminf_{n \to \infty}

1.3.5. 向上、向下取整

1.3.5.1. 向上取整

⌈ a ⌉ \lceil a \rceil a: \lceil a \rceil

⌈ 3.14 ⌉ = 4 \lceil 3.14 \rceil = 4 3.14=4

1.3.5.2. 向下取整

⌊ a ⌋ \lfloor a \rfloor a: \lfloor a \rfloor

⌊ 3.14 ⌋ = 3 \lfloor 3.14 \rfloor = 3 3.14=3

1.4. 公式

1.4.1. 更改公式Cases中每行之间的间距

1.4.1.1. Equation 8pt spacing

在首行\\后,增加需要添加的行距大小,如下 [8pt]

\begin{equation}
    \begin{cases}
        & \Big( \dfrac{\partial}{\partial t} + (u_t + c) \dfrac{\partial}{\partial x} J_{+} \Big) = 0\\[8pt]
        & \Big( \dfrac{\partial}{\partial t} + (u_t - c) \dfrac{\partial}{\partial x} J_{-} \Big) = 0
    \end{cases}
\end{equation}
1.4.1.2. Equation auto spacing

\\后无[8pt],则效果为

\begin{equation}
    \begin{cases}
        & \Big( \dfrac{\partial}{\partial t} + (u_t + c) \dfrac{\partial}{\partial x} J_{+} \Big) = 0\\
        & \Big( \dfrac{\partial}{\partial t} + (u_t - c) \dfrac{\partial}{\partial x} J_{-} \Big) = 0
    \end{cases}
\end{equation}

1.4.2. 公式过长修改

Reference

(更新中)记录 LaTeX 遇到过的问题

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{equation}
    \resizebox{.9\hsize}{!}{$A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z$}
\end{equation}

\end{document}

1.4.3. 公式内空格

  1. \quad 生一个宽度为1em的空格;
  2. \qquad产生一个宽度为2em的空格;
  3. \, 产生一个窄空格,通常用于数字与单位之间的间隔;
  4. \:产生一个比\,宽一点的窄空格
  5. \;产生一个比 \:宽一点的窄空格
  6. \!产生一个负的窄空格,通常用于消除紧贴其后的字符之间不必要的间隔。
\documentclass{article}
\usepackage{amsmath}

\begin{document}

公式内的空格: \\
$\int_{0}^{1} x\,dx$ \\
$\sqrt{a}\qquad \sqrt{a+\frac{b}{c}}\qquad \sqrt[n]{1+x+x^2+\dots+x^n}$ \\
$\sum_{i=1}^{n} a_i$ \\
$a\!+\!b$ \\
$f(x)\!=\!\alpha\!+\!\beta x\!+\!\gamma x^2$

\end{document}

Fig10

1.5. 换行与换页

LaTeX默认是不换行的,并且默认内容超过一页的话就自动换页。但是有时候我们需要强制换行强制换页操作,这个时候就需要用到LaTeX的换行换页命令了。这里介绍如何在LaTeX里面进行强制换行,换页操作。

1.5.1. 换行

1.5.1.1. `\par``

\par命令用在需要换行的内容前面,将之后的内容进行换行操作.

1.5.1.2. `\``

\\用在每一行的末尾,之后的内容便会出现在新的一行。

1.5.2. 换页 `\newpage``

\newpage之后为下一页内容。

1.5.3. Example

\documentclass{letter}

\begin{document}
This is the first line.
\par{This is the second line.}\\
This is the 3rd line.
\newpage
New page.
\end{document}

显示结果:

Fig3

Fig4

1.6. 表格 Table

1.6.1. 指定表格长度和宽度

Reference

【latex技巧】设置表格的长度宽度,单元格指定宽度,自动换行,对齐

1.6.1.1. 指定表格的整体长度和宽度

\begin{tabular}前使用\resizebox{0.8\textwidth}{20cm}{},即可自动缩放表格,其中\textwidth是正文宽度。第一个参数是表格宽度,第二个参数是表格长度,第三个参数是tabular表格。

使用resizeboxcommand需要添加宏包\usepackage{graphicx}

Example:

\resizebox{0.8\textwidth}{!}{
  \begin{tabular}
  \end{tabular}
}

Fig8-table resize

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{table}[!h]
    \resizebox{0.9\textwidth}{!}{
        \begin{tabular}{l | c | r}
            \hline
            Column 1 & Column 2 & Column 3\\
            \hline
            1-1 & 2-1 & 3-1\\
            \hline
            1-2 & 2-2 & 3-2\\
            \hline
        \end{tabular}
    }
\end{table}

\end{document}
1.6.1.2. 设置单元格自动换行,及居中/靠左/靠右

\usepackage{tabularx}调用tabularx宏包,来使用tabular

设置单元格格式时使用诸如m{2cm<{\raggedright},即可指定单元格内容左对齐、宽度2cm、自动换行

参数含义:m 垂直居中,b 垂直靠上,p 垂直靠下。

2cm是单元格宽度

\raggedright 靠左,\centering 居中,\raggedleft 靠右。

Fig8-table align

\documentclass{article}

\usepackage{tabularx} % adjust the width of tabular table

\begin{document}

\begin{tabular}{m{0.1\textwidth}<{\raggedright} | b{0.8\textwidth}<{\centering} | p{0.1\textwidth}<{\raggedleft}}
    \hline
    Column 1 & Column 2 & Column 3\\
    \hline
    column one is what & {column two\newline can change new line\newline and be centered top aligned} & right bottom aligned\\
    \hline
\end{tabular}

\end{document}

注意:\multirow的单元格自动换行需要使用 \multirow{10}{3cm}{内容}

第一个参数是对多少行进行合并,第二个参数是该单元格宽度,超过则会自动换行\multirow{10}{*}表示不自动换行

1.6.2. 表格整体改变颜色

\begin{tabular}之前使用\textcolor{red}{表格内容}

Fig8-table color

\documentclass{article}

\usepackage{tabularx} % change the width and text alignment of the "tabular" table

\usepackage{color} % use "\textcolor"

\begin{document}

\textcolor{red}{
    \begin{tabular}{m{0.1\textwidth}<{\raggedright} | b{0.8\textwidth}<{\centering} | p{0.1\textwidth}<{\raggedleft}}
        \hline
        Column 1 & Column 2 & Column 3\\
        \hline
        column one is what & {column two\newline can change new line\newline and be centered top aligned} & right bottom aligned\\
        \hline
    \end{tabular}
}

\end{document}

1.7. 列表

Reference

LaTex 列表

列表可以通过\itemize{}, \list{}, \enumerate{}, \description{}环境进行表达。

1.7.1. 自定义itemize编号格式

Reference

Latex自定义itemize的编号格式

1.7.1.1. 默认的itemize编号格式

Level 1 是 \textbullet (•)
Level 2 是 \textendash (–)
Level 3 是 \textasteriskcentered (*)
Level 4 是 \textperiodcentered (·).

Fig5-itemize default

\begin{itemize}
    \item  First Level
    \begin{itemize}
      \item  Second Level
      \begin{itemize}
        \item  Third Level
        \begin{itemize}
          \item  Fourth Level
        \end{itemize}
      \end{itemize}
    \end{itemize}
\end{itemize}
1.7.1.2. 重新定义各层的符号

可以把renewcommand命令加在preamble导言区,这样可以实现全局修改。(推荐使用

这些符号可以通过renewcommand{}{}命令重新定义,第一个参数是要定义的层级,第二个参数是新定义的符号样式。

preamble中,即在\documentclass{}\begin{document}之间,添加新的符号定义。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% put 'renewcommand' in the preamble
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\labelitemi}{+} % renew the 1st level of itemize into "+" symbol
\renewcommand{\labelitemii}{-} % renew the 2nd level of itemize into "-" symbol
\renewcommand{\labelitemiii}{*} % renew the 3rd level of itemize into "*" symbol
\renewcommand{\labelitemiv}{\textbullet} % renew the 4th level of itemize into "\textbullet" symbol

注意那个labelitemi,你想改第几个level的符号,你就改那个i

labelitemi 对于 Level 1
labelitemii 对于 Level 2
labelitemiii 对于 Level 3
labelitemiv 对于 Level 4

Fig5-itemize renew

\begin{itemize}
    \item  First Level
    \begin{itemize}
      \item  Second Level
      \begin{itemize}
        \item  Third Level
        \begin{itemize}
          \item  Fourth Level
        \end{itemize}
      \end{itemize}
    \end{itemize}
\end{itemize}
1.7.1.3. 修改特定item的符号
\begin{itemize}
  \item  Default item label for entry one
  \item  Default item label for entry two
  \item[+]  Custom item label for entry three
\end{itemize}

1.7.2. 自定义enumerate编号格式

Reference

LaTex 列表

\renewcommand可以通过使用重新定义标签生成命令来配置 LaTeX \LaTeX LATEX的标准标签,并且对于enumerate环境,您还可以使用适当的计数器变量。

1.7.2.1. 默认的enumerate编号格式

Fig6-enumerate default

\documentclass{article}

\begin{document}

\begin{enumerate}
    \item First level item
    \item First level item
    \begin{enumerate}
        \item Second level item
        \item Second level item
        \begin{enumerate}
            \item Third level item
            \item Third level item
            \begin{enumerate}
                \item Fourth level item
                \item Fourth level item
            \end{enumerate}
        \end{enumerate}
    \end{enumerate}    
\end{enumerate}

\end{document}
1.7.2.2. enumerate各级序号连续累加

Fig6-enumerate renew

\documentclass{article}

\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}} % enumerate 2nd level with previous item number
\renewcommand{\labelenumiii}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}} % enumerate 3rd level with previous item number
\renewcommand{\labelenumiv}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}.\arabic{enumiv}}

\begin{document}

\begin{enumerate}
    \item One
    \item Two
    \item Three
    \begin{enumerate}
        \item Three point one
        \begin{enumerate}
        \item Three point one, point one
            \begin{enumerate}
            \item Three point one, point one, point one
            \item Three point one, point one, point two
            \end{enumerate}
        \end{enumerate}
    \end{enumerate}
    \item Four
    \item Five
\end{enumerate}

\end{document}
1.7.2.3. 列表计数器的变量

在前面的示例中,该命令\arabic用于排版各种标签计数器变量的当前值。请注意,“阿拉伯数字”和命令的使用\arabic是指数字0到9.

通常,可以使用以下 5 个命令之一以各种格式打印 计数器变量:

\arabic{counter variable}
\roman{counter variable}
\Roman{counter variable}
\Alph{counter variable}
\alph{counter variable}

Example:

在这里插入图片描述

\documentclass{article}

\begin{document}

\begin{verbatim}
    \newcounter{foo}
    \setcounter{foo}{2}
\end{verbatim}

\newcounter{foo}
\setcounter{foo}{2}

\begin{itemize}
    \item \verb|\arabic{foo}| produces \arabic{foo}
    \item \verb|\roman{foo}| produces \roman{foo} 
    \item \verb|\Roman{foo}| produces \Roman{foo}
    \item \verb|\Alph{foo}| produces \Alph{foo}
    \item \verb|\alph{foo}| produces \alph{foo}
\end{itemize}

\end{document}

1.8. 对齐

1.8.1. 右对齐

实现从一个位置开始,将后面部分右对齐

1.8.1.1. 正文中右对齐

(1)通过添加\hfill,可参考一下示例

\documentclass{article}

\begin{document}

Some text \hfill This text is right-aligned.

\end{document}

(2)如果要实现一段文字右对齐,可使用flushright环境,如下

\documentclass{article}

\begin{document}

\begin{flushright}
This text is right-aligned.
\end{flushright}

\end{document}

效果显示:

Fig11

1.8.1.2. 公式中右对齐

在LaTeX中,公式默认是居中对齐的,而无法直接在公式中的某个位置将内容右对齐到页面最右端。不过,可以通过一些其他的方法来实现这个效果。

一种常用的方法是使用\hfill命令配合\tag*{}命令,将某个位置之后的内容右对齐到页面最右端,并将其标记为一个自定义的标签。以下是一个示例:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
    a &= b + c \\
    d &= e + f + g \tag*{\hfill$(\text{Right-aligned text})$}
\end{align*}

\end{document}

在上述示例中,我们使用\tag*{}命令将\hfill$(\text{右对齐的内容})$作为标签添加到第二行的末尾。\tag*{}命令的作用是在不打印编号的情况下添加一个自定义的标签。结合\hfill命令,标签将会右对齐到页面最右端。

效果显示:

Fig12

其中,\tag*{}内是文本格式,所以如果需要输出公式则需要添加$$符号;如果只有文字,则可以直接输入文字,或者使用$\text{}$

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值