a site to share moments and soughts~

Victor's blog


  • Home
  • Archive
  • Tags
  • about
  •   

© 2025 Victor

Theme Typography by Makito

Proudly published with Hexo

关于LaTeX尾注

Posted at 2024-09-05 操作 

edition1

要将尾注的数字加上中括号,您可以自定义一个新的脚注命令。这里是一种实现方式:

  1. 在文档的导言区(preamble)添加以下代码:
1
2
3
4
5
6
7
8
9
\usepackage{etoolbox}
\renewcommand{\thefootnote}{[\arabic{footnote}]}
\makeatletter
\patchcmd{\@makefntext}{%
\hss\@makefnmark
}{%
\hss\@makefnmark\enspace
}{}{}
\makeatother
  1. 然后在正文中使用 \footnote 命令时,就会自动在脚注中显示带中括号的数字。

例如:

1
这是一个示例句子\footnote{这是脚注内容}。

这将产生一个带有 “[1]” 样式的脚注。

如果您只想在特定的脚注中使用中括号,而不是全局更改,您可以定义一个新的命令:

1
\newcommand{\bracketfootnote}[1]{\footnote{[\arabic{footnote}] #1}}

然后在需要使用带中括号的脚注时使用此命令:

1
这是一个示例句子\bracketfootnote{这是带中括号的脚注内容}。

这样,您就可以灵活地在带中括号和不带中括号的脚注之间切换了。

edition2

明白了,您希望能够为尾注指定特定的数字,而不是自动递增的编号。我们可以进一步修改自定义命令来实现这一点。以下是一种可行的方法:

  1. 在导言区定义修改后的自定义命令:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\usepackage{hyperref}  % 如果需要超链接功能

\newcommand{\myendnote}[2]{%
\textsuperscript{[#1]}%
\hypertarget{endnote:#1}{}%
\expandafter\gdef\csname endnote#1\endcsname{#2}%
}

\newcommand{\printmyendnotes}{%
\begin{enumerate}
\foreach \x in {1,...,9} {%
\ifcsname endnote\x\endcsname
\item[\textsuperscript{[\x]}] \hyperlink{endnote:\x}{}\csname endnote\x\endcsname
\fi
}
\end{enumerate}
}
  1. 在正文中使用时,指定尾注编号:
1
2
3
这是一个需要尾注的句子\myendnote{1}{这是第一个尾注内容}。
这是另一个需要尾注的句子\myendnote{2}{这是第二个尾注内容}。
这是第三个需要尾注的句子\myendnote{3}{这是第三个尾注内容}。
  1. 在文档末尾打印尾注的方式不变:
1
2
3
\clearpage  % 或 \newpage
\section*{尾注}
\printmyendnotes

这种修改后的方法有以下特点:

  1. 您可以为每个尾注指定特定的编号。
  2. 在正文中,尾注编号会以上标的中括号形式显示,例如 [¹]、[²]、[³] 等。
  3. 不会在页面底部显示尾注内容。
  4. 在文档末尾的尾注部分,每个尾注项会按指定的编号排列。
  5. 保留了超链接功能(如果使用了 hyperref 包)。

注意事项:

  1. 这个方法允许您使用 1-9 的编号。如果需要更多编号,可以在 \printmyendnotes 命令中扩展范围。
  2. 确保不要重复使用相同的编号,否则后面的内容会覆盖前面的。
  3. 您不必按顺序使用编号,可以根据需要跳过某些数字。

如果您想进一步自定义尾注的样式或格式,可以在 \myendnote 和 \printmyendnotes 命令中进行调整。

edition3

当然可以。我们可以修改自定义命令,使尾注编号在文中以中括号形式显示。以下是修改后的方法:

  1. 在导言区定义修改后的自定义命令:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
\usepackage{hyperref}  % 如果需要超链接功能

\newcounter{endnotecounter}
\renewcommand{\theendnotecounter}{\arabic{endnotecounter}}

\newcommand{\myendnote}[1]{%
\refstepcounter{endnotecounter}%
\textsuperscript{[\theendnotecounter]}%
\hypertarget{endnote:\theendnotecounter}{}%
}

\newcommand{\printmyendnotes}{%
\setcounter{endnotecounter}{0}%
\begin{enumerate}
\foreach \x in {1,...,\value{endnotecounter}} {%
\item[\textsuperscript{[\x]}] \hyperlink{endnote:\x}{}
}
\end{enumerate}
}
  1. 在正文中使用方式不变:
1
2
这是一个需要尾注的句子\myendnote{这是尾注内容}。
这是另一个需要尾注的句子\myendnote{这是另一个尾注内容}。
  1. 在文档末尾打印尾注的方式也不变:
1
2
3
\clearpage  % 或 \newpage
\section*{尾注}
\printmyendnotes

这种修改后的方法有以下特点:

  1. 在正文中,尾注编号会以上标的中括号形式显示,例如 [¹]、[²] 等。
  2. 不会在页面底部显示尾注内容。
  3. 在文档末尾的尾注部分,每个尾注项也会以中括号形式编号。
  4. 保留了超链接功能(如果使用了 hyperref 包)。

如果您想进一步调整尾注的样式,例如改变中括号的大小或颜色,可以在 \myendnote 命令中进行更多自定义。例如:

1
2
3
4
5
\newcommand{\myendnote}[1]{%
\refstepcounter{endnotecounter}%
\textsuperscript{\small[\theendnotecounter]}%
\hypertarget{endnote:\theendnotecounter}{}%
}

这会使中括号稍微小一些。您可以根据需要进行更多调整。

Share 

 Previous post: Mac 安装Node.js 20 后`node -v` 和 `npm -v`找不到的解决方案 Next post: notes_The Python Book_20240418 

© 2025 Victor

Theme Typography by Makito

Proudly published with Hexo