一、Latex圖片編號位置
在Latex中插入圖片時候,可以使用\includegraphics命令, 在該命令的後面加上\label{fig:labelname}, 這樣編號就與這個圖片的引用聯繫起來了。用\ref{fig:labelname}來引用這個編號。而這個編號的位置一般放在caption的後面。代碼如下:
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{picture.png}
\caption{A picture}
\label{fig:picture}
\end{figure}
二、Latex圖片位置調整
圖片的位置有一定的規則,一般按照htbp的順序,第一個h表示放置在該位置,如果位置不夠自動調整位置到下一個t(top)、b(bottom)或p(page)。可以使用h!,強制置於當前位置。如果圖片比較大,使用h!可能會使圖片上下文的空白浪費過多,所以也可以使用float環境如:
\begin{figure}[htbp]
\begin{minipage}[t]{0.48\linewidth}%設置圖片並排放置,不推薦浮動環境
\centering
\includegraphics[width=\textwidth]{picture1.eps}
\caption{picture1 caption}%圖片1的名稱
\end{minipage}
\hspace{0.04\linewidth}%這裡如果沒有空白的話圖片會挨著放
\begin{minipage}[t]{0.48\linewidth}%兩個minipage之間不能有空行
\centering
\includegraphics[width=\textwidth]{picture2.eps}
\caption{picture2 caption}%圖片2的名稱
\end{minipage}
\end{figure}
三、Latex圖片編號設置
Latex中默認的圖片編號是按照「章節.圖片」這樣的格式的,比如「1.1」表示第1章第1個圖片。如果想要去掉章節編號,或者改為其他樣式可以使用命令\renewcommand{\thefigure}{\thesection.\arabic{figure}}(取消注釋即可)。這裡的\thesection 表示章節編號,\arabic{figure}表示圖片編號。下面是代碼如下:
%\renewcommand{\thefigure}{\thesection.\arabic{figure}}%取消注釋則取消章節編號
\setcounter{figure}{0}%重新編號,如果前面取消了章節編號需要加這個
四、Latex圖片調整位置
圖片的大小和位置可以使用graphicx宏包的scale(比例)和width(寬度)命令,比如\includegraphics[scale=0.4]{picture}或者\includegraphics[width=7cm]{picture},也可以將其調整到與正文一樣的大小,或者加上位置等信息。下面是一個例子:
\begin{figure}[h!]
\centering
\includegraphics[width=\textwidth]{picture.png}
\caption{A picture}
\label{fig:picture}
\end{figure}
五、Latex圖片參數設置
可以在命令中添加參數控制圖片的大小和位置,比如插入left=3em, right=4em位於頁面左右邊距的兩張圖片,代碼如下:
\begin{minipage}[t]{0.4\linewidth}
\includegraphics[width=\textwidth,left=3em]{leftpicture}
\caption{Picture on the left}
\label{fig:leftpicture}
\end{minipage}
\hspace{1cm}
\begin{minipage}[t]{0.4\linewidth}
\includegraphics[width=\textwidth,right=4em]{rightpicture}
\caption{Picture on the right}
\label{fig:rightpicture}
\end{minipage}
六、Latex圖片名稱設定
參考前文的代碼,用\caption{picture name}命令即可設定圖片名稱。還可以使用Subcaption分別定義子圖的名稱。代碼如下:
\usepackage{subcaption}
\begin{figure}[htbp]
\centering
\subcaptionbox{Subfigure 1's caption}[0.4\linewidth]{\includegraphics[width=0.4\linewidth]{picture1.jpg}}
\quad
\subcaptionbox{Subfigure 2's caption}[0.4\linewidth]{\includegraphics[width=0.4\linewidth]{picture2.jpg}}
\caption{Picture's caption}
\label{fig:picture}
\end{figure}
七、Latex圖片標註來源
處理源和圖片可以直接用表格處理,使用caption宏包的font命令自定義字體大小。例如下面的代碼是一個矩陣,處理辦法在caption中加入labelsep定義姓與名字之間的間隔,skip設置行距,labelfont設置字體。
\begin{table}[h!]
\centering
\captionsetup{font={scriptsize,labelsep=space,skip=5pt,labelfont=bf}}
\caption*{\textbf{Source}: XXXX. (2022). XXX.}
\begin{tabular}{|c|c|c|c|}
\hline
& A & B & C \\
\hline
D & 1 & 2 & 3 \\
\hline
E & 4 & 5 & 6 \\
\hline
F & 7 & 8 & 9 \\
\hline
\end{tabular}
\label{tab1}
\end{table}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/151976.html
微信掃一掃
支付寶掃一掃