LaTeX 引用章节、公式和图表

140 篇文章 4 订阅
9 篇文章 0 订阅

原  文:Cross referencing sections, equations and floats
译  者:Xovee
翻译时间:2021年6月4日

引用章节、公式和图表

如果你想在 LaTeX 文档中使用数字(或者其他引用格式)来引用文档中的公式、章节、图片等元素,本篇文章将会教给你具体的做法。

介绍

下面是一个简单的引用图片的例子:

\section{Introduction} \label{introduction}
This is an introductory paragraph with some dummy text. This section will be referenced later.

\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{overleaf-logo}
\caption{This image will be referenced below.}
\label{fig:leaf}
\end{figure}

You can reference images; for instance, Figure \ref{fig:leaf} shows the \textit{Overleaf} logo.

在这里插入图片描述
命令\label{}创建了一个图题之后的标识符,这个标识符随后被命令\ref{}使用来创建引用数字(或者其他引用格式)。

引用章节

下面是一个引用章的例子:

\section{Introduction} \label{introduction}
This is an introductory paragraph with some dummy text. This section will be referenced later.

\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{overleaf-logo}
\caption{This image will be referenced below.}
\label{fig:leaf}
\end{figure}

You can reference images; for instance, Figure \ref{fig:leaf} shows the \textit{Overleaf} logo.
\vspace{0.5cm}

\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can be referenced within a document.

在这里插入图片描述
与上一个例子相似,这个例子使用了\label\ref命令来创建引用。在\section命令之后使用\label命令,也就是说,你应该在章的编号被创建之后来使用\label命令。这个方法对chapters、subsections 以及 subsubsections 都有效。具体参考这篇文章

引用公式、图片和表格

在本章的开头,我们看到了一个引用图片的例子,下面介绍如何引用公式:

\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can be referenced within a document.

\subsection{Powers series} \label{subsection}

\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}

Equation \ref{eq:1} is a typical power series.

在这里插入图片描述

引用元素所在页

文档中的元素一般使用数字来引用它们。如果你需要的话,你也可以引用它们所在的页数字。

\section{Math references} \label{mathrefs}
As mentioned in section \ref{introduction}, different elements can be referenced within a document.

\subsection{Powers series} \label{subsection}

\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}

Equation \ref{eq:1} is a typical power series.
\vspace{0.5cm}

%\Blindtext

\section{Last section}
In subsection \ref{subsection} on page \pageref{eq:1} an example of a power series was presented.

在这里插入图片描述
命令\pageref会插入元素(对应所使用的\label)所在的页数。这个命令适用于本文中所有的可编号元素。

编译带有引用的文档

在 Overleaf 平台上,交叉引用是立即生效的。对于本地的 LaTeX 编译环境,你必须编译文档两次来使交叉引用生效。你也可以使用特定的命令来使所有的交叉引用生效。例如,如果你的文档是main.tex,你可以使用下面的命令

latexmk -pdf main.tex

来生成main.pdf文件。文件中所有的交叉引用都会生效。如果你要改变输出的格式,使用-dvi或者-ps参数。

  • 30
    点赞
  • 99
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值