LaTeX学习-day05
教程链接:B站
使用环境:
- 系统:Windows 10
- TeX 系统:TeX Live (官网下载)(清华源)
- IDE:Tex Studio
- 代码:
% 导言区
\documentclass{ctexart}
\usepackage{graphicx}
\graphicspath{{figures/}}%t图片在当前目录下的figure目录,也可以添加多个路径:\graphicspath{{figures/},{pics/}}
%语法:\includegraphics[<选项>]{<文件名>}
%格式:EPS,PDF,PNG,JPEG,BMP
%正文区(文档区)
\begin{document}
\LaTeX{}中插图
%原图
\includegraphics{jepg.jpg}
\includegraphics{eps.eps}
%缩放因子
\includegraphics[scale=0.3]{jepg.jpg}
\includegraphics[scale=0.03]{eps.eps}
%固定高度
\includegraphics[height=2cm]{jepg.jpg}
\includegraphics[height=2cm]{eps.eps}
%固定宽度
\includegraphics[width=2cm]{jepg.jpg}
\includegraphics[width=2cm]{eps.eps}
%固定文本高度
\includegraphics[height=0.1\textheight]{jepg.jpg}
\includegraphics[height=0.1\textheight]{eps.eps}
%固定文本宽度
\includegraphics[width=0.2\textwidth]{jepg.jpg}
\includegraphics[width=0.2\textwidth]{eps.eps}
%旋转角度
\includegraphics[angle=-45,width=0.2\textwidth,height=0.1\textheight]{jepg.jpg}
%查询指令texdoc graphicx
%from CSDN:插图
Latex的插图 \\
\includegraphics[scale=0.3]{jepg.jpg} \\
浮动体 \\
一般情况下我们很少会把图片直接插入到我们的文本当中,而是会给它放置在一个叫做浮动体(float)的东西中。这样图片可以有一些相对位置的变换,不会造成分页困难等问题。 \\
\begin{figure}[ht]
\centering
\includegraphics[scale=0.1]{jepg.jpg}
\caption{this is a figure demo}
\label{fig:label}
\end{figure} \\
浮动体环境:figure \\
选项:[ht]是可选项 \\
h 此处(here) \\
t 页顶(top) \\
b 页底(bottom) \\
p 独立一页(page) \\
使用figure表示的是把我们这个东西看成一个段落并且是没有任何缩进的 \\
% \centering表示的是里面紧跟的内容都居中
% \includegraphics[]{}表示的插入图片
% \caption设置图片的一个编号以及为图片添加标题
相对路径插入 \\
我们在写论文的时候,一般如果图片比较多我们一般会选择把图片统一的放到和源文件一个路径下的某个目录里,这个时候我们要成功的加载图片我们就可以使用相对路径来加载。 \\
如我们把图片全部放在一个叫做figures的文件夹下面,如图所示: \\
\begin{figure}[ht]
\centering
\includegraphics[scale=0.1]{figures/eps.eps}
\caption{this is a figure demo}
\label{fig:pathdemo}
\end{figure} \\
绝对路径插入图片 \\
有相对路径当然还有绝对路径,使用绝对路径插入图片的代码如下所示,使用与windows系统和linux系统。 \\
\begin{figure}[ht]
\centering
\includegraphics[scale=0.1]{E:/Documents/LaTeX/Study/texTest/figures/jepg.jpg}
\caption{this is a figure demo}
\label{fig:pathdemo1}
\end{figure} \\
跨双栏插入图片 \\
在figure后面加*号这样就可以把单栏的图片双栏显示了 \\
\begin{figure*}[ht]
\centering
\includegraphics[scale=0.1]{eps.eps}
\caption{this is a figure demo}
\label{fig:pathdemo4}
\end{figure*}
\end{document}
- 结果