📢 This article was translated by gemini-3-flash-preview
Add the following code to your preamble. The second line sets the default image path to the img/ folder.
1
2
3
| % Image
\usepackage{graphicx}
\graphicspath{{img/}} % set default path to img/
|
Standard usage:
1
2
3
4
5
6
| \begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{example.jpg}
\caption{caption}
\label{fig:label}
\end{figure}
|
The htbp parameters stand for:
h: here (current position)t: topb: bottomp: page (new page)
The [width=0.8\textwidth] setting makes the image 80% of the line width. The caption is the description below the figure, and the label is for cross-referencing:
1
| Refer to Figure \ref{fig:label}
|
If you don’t need individual captions for each image, you can arrange them simply:
1
2
3
4
5
6
7
| \begin{figure}[htbp]
\centering
\includegraphics[width=0.45\textwidth]{image1.jpg}
\hspace{0.05\textwidth} % spacing
\includegraphics[width=0.45\textwidth]{image2.jpg}
\caption{Two images side-by-side sharing one caption}
\end{figure}
|
If you need separate captions for each, use minipage:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| \begin{figure}[htbp]
\centering
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{pic1.png}
\caption{pic1 description}
\label{fig:pic1}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=0.4\textwidth]{pic2.png}
\caption{pic2 description}
\label{fig:pic2}
\end{minipage}
\end{figure}
|
Tables
Add these to your preamble:
1
2
| \usepackage{tabularx} % add table
\usepackage{booktabs} % table function \toprule, \midrule, \bottomrule
|
Table structure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| \begin{table}[htbp]
\small
\centering
\begin{tabularx}{\textwidth}{l|l|X}
\toprule
\textbf{title1} & \textbf{title2} & \textbf{title3} \\
\midrule
content1-1 & content1-2 & content1-3 \\
\cmidrule{2-3}
& content2-2 & content2-3 \\
\midrule
content3-1 & content3-2 & content3-3 \\
\bottomrule
\end{tabularx}
\end{table}
|
Use \midrule to draw a line across all columns. Use \cmidrule for specific columns; for example, \cmidrule{2-3} draws a line only from the second to the third column.