Latex 交叉引用图片时编译没有问题,pdf 文件中却显示?? 或者不显示 ------ 解决方案

最近写report 遇到一个问题,就是在图片或表格的交叉引用时, 便已没有问题,正文中相应位置显示 ?? 或者不显示, 查了相关资料之后发现问题出在\label{}\caption{} 的前后顺序上。
问题如下:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
	The price of several fruits are in Table \ref{table1}:
	\begin{table}[ht]
		\centering
		\begin{tabular}{cc}
			\toprule
			types    & Price  \\ 
			\midrule
			Apple & 10\\
			Banana  & 9\\
			Pear & 12   \\ 
			\bottomrule
		\end{tabular}
	\label{table1}
	\caption{The price table.}
	\end{table}
\end{document}

相应的PDF文件如下: 没有显示 Table 后并没有出现1, 编译没有错误:
在这里插入图片描述

正确的顺序应该是:\label{}应该在\caption{}的后边,如下所示。

\documentclass{article}
\usepackage{booktabs}
\begin{document}
	The price of several fruits are in Table \ref{table1}:
	\begin{table}[ht]
		\centering
		\begin{tabular}{cc}
			\toprule
			types    & Price  \\ 
			\midrule
			Apple & 10\\
			Banana  & 9\\
			Pear & 12   \\ 
			\bottomrule
		\end{tabular}
	\caption{The price table.}
	\label{table1}
	\end{table}
\end{document}

生成的pdf 文件如下:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值