LaTeX中显示图像
目录
插入图片
假设现在有张图片,路径为./images/universe.jpg
,希望导入到文档中,代码如下。
\documentclass{article}
\usepackage{graphicx} % 插入图片必要的宏包
\graphicspath{ {./images/} } %主目录下包含图片的路径
\begin{document}
The universe is immense and it seems to be homogeneous,
in a large scale, everywhere we look at.
\includegraphics{universe} % 插入图片(输入图片前缀名)
\end{document}
补充
1.可以使用绝对路径。
\graphicspath{ {c:/user/images/} }
2.可以同时使用两个包含图片的文件夹
\graphicspath{ {./images1/}{./images2/} }
图片添加注解标签和引用
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {images/} }
\begin{document}
\begin{figure}[h]
\centering
\includegraphics[width=0.25\textwidth]{mesh}
\caption{a nice plot}
\label{fig:mesh1}
\end{figure}
As you can see in the figure \ref{fig:mesh1}, the
function grows near 0. Also, in the page \pageref{fig:mesh1}
is the same example.
\end{document}
之后,还会补充一些关于插入图片的用法。现在发现latex真的很方便,通过label
和ref
对应,引用的Figure
编号和页码都自动设置。
参考