1. 程式人生 > >(研究生)LaTex論文排版:插入圖片及相關功能

(研究生)LaTex論文排版:插入圖片及相關功能

LaTex 論文排版:


1.一般圖片插入

導言區

\usepackage{graphicx}      % insert graphic

正文

\begin{figure*}
\includegraphics[width=0.75\textwidth]{fig5.png}
\caption{PSD diagram}
\label{fig:5}       % Give a unique label
\end{figure*}

可以獲得如下的輸出:
這裡寫圖片描述
可以看出 圖注在圖片的下方(但不是正下方,如果想在正下方,需要在正文中加入\centering

2.圖注在圖片右下方

(這個是以springer的模板,預設的在右下方。其實也不需要特別做修改到左上方,因為最終的layout還是要由springer的stuff來確定:這句話是來源於外網 tex求助區)使用了\sidecaption
導言區

\usepackage{graphicx}      % insert graphic

正文

\begin{figure}\sidecaption     %figure legend圖注   把題注放在 右下方
\resizebox{0.3\hsize}{!}{\includegraphics*{example.eps}}
\caption{A figure}
\end{figure}

可以獲得如下的輸出:
輸出的圖片
可以看出 圖注在圖片的左邊

3.左右排+上下排

###左右排
導言區

\usepackage{graphicx}      % insert graphic
\usepackage{subcaption}

正文

\begin{figure*}\sidecaption
 \begin{minipage}{5cm}
 \centering
  \includegraphics[width=1\textwidth]{fig1.png}
  \subcaption{fig1}
  \end{minipage}
  \begin{minipage}{5cm}
  \centering
  \includegraphics[width=1\textwidth]{fig1.png}
  \subcaption{fig2}
  \end{minipage}
\caption{1111}
\end{figure*}

可以獲得如下的輸出:
這裡寫圖片描述

上下排

導言區不變
正文

\begin{figure*}\sidecaption
 \begin{minipage}{5cm}
  \includegraphics[width=1\textwidth]{fig1.png}
  \subcaption{fig1}
  \includegraphics[width=1\textwidth]{fig1.png}
  \subcaption{fig2}
  \end{minipage}
\caption{1111}
\end{figure*}

結果如圖所示:
這裡寫圖片描述

4.使用subcaption插入並排圖片

在引言處加入
\usepackage{subcaption}

\begin{figure}[H]
		\caption{經緯線提取樣例}
		\label{fig:example}
		\begin{subfigure}{.5\textwidth}
			\centering
			\includegraphics[width=\textwidth]{before.png}
			\caption{提取經緯線前}
		\end{subfigure}
		\begin{subfigure}{.5\textwidth}
			\centering
			\includegraphics[width=\textwidth]{after.png}
			\caption{提取經緯線後}
		\end{subfigure}
	\end{figure}

這裡寫圖片描述
此處參考了wiki百科關於latex圖片排版的知識:https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
##5.使用SC環境來使得題注放置在其他位置##
SC指的是 sidecaption 表示 旁邊的題注

\begin{SCfigure}
  \centering
  \includegraphics[width=0.5\textwidth]{atoms_in_cavity.jpg}
  \caption{A picture of a gull}
\end{SCfigure}

6.將圖注放在左上方的一種方法##

記得新建一個檔案,寫下這段程式碼

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[innercaption]{sidecap}
\sidecaptionvpos{figure}{t}

\begin{document}

\begin{SCfigure}
  \begin{minipage}{9cm}
  \subcaptionbox{A subfigure\label{fig:sub1}}{\includegraphics[width=1\textwidth]{fig1.png}}\\
  %若去掉\\後則是橫排,特別注意
  \subcaptionbox{Another subfigure\label{fig:sub2}}{\includegraphics[width=1\textwidth]{fig1.png}}
  \end{minipage}
  \caption{11111111111111111111111dhfsdfjsddfkkkkkkk\protect\\sfsjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk}
\end{SCfigure}

\end{document}

得到的圖片如圖所示:這裡寫圖片描述

但是仍和標準的排版有差距(待解決),以下圖片為 標準論文圖片:
這裡寫圖片描述

為了本處的東西,問了百度知道,小木蟲,知乎,最後在知乎上有個大佬給了一個連結,是從這個連結中得到答案的:
https://tex.stackexchange.com/questions/47927/placing-caption-on-the-top-right-or-top-left?answertab=active#tab-top

大佬還說了一句話,多用用Google,我深表認同
##7.caption過長換行##
用latex寫論文時caption往往會過長,導致兩幅圖的caption貼在一起很不美觀,這時就需要換行了。
雖然直接用\都可以達到效果,但往往會報錯或警告。
這時候就要使用\protect保護一下啦,即\protect\\即可。
##8.caption重置##

\usepackage{caption}
\usepackage[labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedleft]{caption}
\usepackage{subcaption}
\usepackage[labelfont=normalfont,textfont=normalfont,singlelinecheck=off,justification=default]{subcaption}

注意:labelfont表示 標號字型(例如Fig1) text font表示 標題內容字型
bf表示 加粗
jusitification表示位置,其中raggerdright 在左方

常用選項[htbp]是浮動格式:
『h』當前位置。將圖形放置在正文文字中給出該圖形環境的地方。如果本頁所剩的頁面不夠,這一引數將不起作用。
『t』頂部。將圖形放置在頁面的頂部。
『b』底部。將圖形放置在頁面的底部。
『p』浮動頁。將圖形放置在一隻允許有浮動物件的頁面上。

一般使用[htb]這樣的組合,只用[h]是沒有用的。這樣組合的意思就是latex會盡量滿足排在前面的浮動格式,就是h-t-b這個順序,讓排版的效果儘量好。
!h 只是試圖放在當前位置。如果頁面剩下的部分放不下,還是會跑到下一頁的。一般頁言,用 [!h] 選項經常會出現不能正確放置的問題,所以常用 [ht]、[htbp] 等。

如果你確實需要把圖片放在當前位置,不容改變,可以用float巨集包的[H]選項。不過如果這樣做,出現放不下的問題時需要手工調整。使用格式如下: \usepackage{float}

   \begin{figure}[H] 
    foo 
   \end{figure}