LoginSignup
2
3

はじめに

大学の授業でlatexでレポートを書かせる授業があったときに、図1-1、図2-1のように画像を提示したかったので、やり方を調べてみました。

実際のコード

\usepackage{graphicx} 
\usepackage{chngcntr} 
\usepackage{caption} 
\renewcommand{\thefigure}{\thesection-\arabic{figure}}

\counterwithin{figure}{section}
\captionsetup[figure]{labelformat=empty}

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.5\linewidth]{images/is0662ks_1-1.png}
    \caption{図\thesection-\arabic{figure}物理シミュレーションで観測したい内容}
    \label{fig:fall-start}
    % \label{fig:enter-label}
\end{figure}

graphicx: 画像を挿入するためのパッケージです。

chngcntr: カウンタの再設定やカウンタのリセットを行うためのパッケージです。

\counterwithin{figure}{section}

これはセクションが変わると、図の番号をリセットしています。

caption: キャプションのスタイルやフォーマットを設定するためのパッケージです。以下の箇所で使われていて、labelの内容だけ表示して、図1-1等を表示しません。

\captionsetup[figure]{labelformat=empty}

セクション番号-何枚目の画像という景色で表示しています

\caption{図\thesection-\arabic{figure}物理シミュレーションで観測したい内容}

ぜひ参考にしてください

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3