忍者ブログ
物理学者(ポスドク)による日々の研究生活のメモ書きです ( python/emacs/html/Japascript/シェルスクリプト/TeX/Mac/C言語/Linux/git/tmux/R/ポケモンGO)
以下のソースだとcaptionがやたら近くなってしまう場合がある
\begin{figure}[htbp]
\begin{minipage}{0.5\hsize}
\begin{center}
\includegraphics[width=\hsize]{hoge.png}
\end{center}
\caption{
This is an example using minipage without parbox. This is an example using minipage without parbox. This is an example using minipage without parbox.
}
\label{fig:hoge1}
\end{minipage}
\begin{minipage}{0.5\hsize}
\begin{center}
\includegraphics[width=\hsize]{hoge.png}
\end{center}
\caption{
This is an example using minipage without parbox. This is an example using minipage without parbox. This is an example using minipage without parbox.
}
\label{fig:hoge2}
\end{minipage}
\end{figure}




そういうときは、parboxを使う
60mmとか80mmって数字は好みで変える
\begin{figure}[htbp]
\begin{minipage}[t]{0.5\hsize}
\begin{center}
\includegraphics[width=\hsize]{hoge.png}
\end{center}
\caption{
\parbox[t]{60mm}{
This is an example using minipage and parbox. This is an example using minipage and parbox. This is an example using minipage and parbox.
}
}
\label{fig:hoge1}
\end{minipage}
\begin{minipage}[t]{0.5\hsize}
\begin{center}
\includegraphics[width=\hsize]{hoge.png}
\end{center}
\caption{
\parbox[t]{60mm}{
This is an example using minipage and parbox. This is an example using minipage and parbox. This is an example using minipage and parbox.
}}
\label{fig:hoge2}
\end{minipage}
\end{figure}
■ 参考 : LaTeXのcaptionサイズ



(2021/11/24 追記)

\begin{minipage}[t]{0.5\hsize}
[t]を追記した
これがあると2枚の図でcaptionの長さが全然違ったときに図の位置がずれてしまうのを防止できる
図の上位置で揃えて並べてくれる





比較画像↓
(このTeXソースだと全然captionが近くないね・・・・)

TeX



(2017/07/02 追記)

上記のminipageだとやはりダメだったので、他の方法を探す
parboxを使うと、Figure. 10みたいな数字がやたら引き延ばされて表示されてしまう

minipageを使うときちんと図は2枚横に並んでくれるのでそれはOKだが
問題はcaptionの付き方
というか別にcaptionが図ごとに付いている必要はあんまりないのだが・・・



■ 参考 : Minipage with four figures - avoiding too much whitespace



ここに自分が求めているような図があった
minipageの代わりにsubfigureというのを使っているらしい
出来上がりはこんな感じ

zVGai



一応、手元での仕上がりもチェックしておく・・・・
ソースコードはこんな感じ
Hって何? って聞かれたら、here.styが入っていないのでHをhtbpとかに置き換えること
\begin{figure}[H]
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\caption{
\parbox[t]{60mm}{
This is hoge. This is hoge. This is hoge. This is hoge. This is hoge.
}
}
\label{fig:lefttop}
\vspace{4ex}
\end{subfigure}%%
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\caption{
\parbox[t]{60mm}{
This is hoge. This is hoge. This is hoge. This is hoge. This is hoge.
}
}
\label{fig:righttop}
\vspace{4ex}
\end{subfigure}
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\caption{
\parbox[t]{60mm}{
This is hoge. This is hoge. This is hoge. This is hoge. This is hoge.
}
}
\label{fig:bottomleft}
\end{subfigure}%%
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\caption{
\parbox[t]{60mm}{
This is hoge. This is hoge. This is hoge. This is hoge. This is hoge.
}
}
\label{fig:bottomright}
\end{subfigure}
\caption{This is total hoge. This is total hoge. This is total hoge. This is total hoge. This is total hoge. }
\label{fig:total}
\end{figure}
仕上がりは、


blog3

(2017/10/04 追記)
上のTeXソースで%%とついているところ、改行を追加してしまうと
つまり、
\end{subfigure}%%

\begin{subfigure}[]{0.5\linewidth}
としてしまうと、横に2枚並ばないので注意
気づくのにかなり時間がかかった・・・・




使っているのはsubfigureだけど、必要なのはsubcaption.styというスタイルシート
subcaption.styの日本語説明は以下にある
■ 参考 : subcaption.sty

subcaption.styのダウンロードは以下から
■ 参考 : Direc­tory install/macros/latex/contrib

たくさんあるけど、caption.tds.zipというのを落とす
解凍したら tex/latex/captionにsubcaption.styがあるので、
tex/latex/captionをTeXが見る場所に置く

詳しい説明は、

■ 過去記事 : 【TeX】 styファイル not foundというエラーが出たのでmktexlsrさんの出番





(2017/07/02 さらに追記)

もうminipageを使うことはたぶんないけど、面白いページを見つけた
minipageでグラフを貼るときの位置指定(htbp)を左と右で変えるとグラフの位置が少しずれてしまうらしい

■ 参考 : minipage 環境





(2017/07/02 さらにさらに追記)

上の図で、(a)とかいうsubcaptionを消せないかなぁ〜と思って
「subcaption no caption」でググってみた
(それもはやsubcaptionいらないじゃん・・・とはちょっと思った)

そしたら、\phantomcaption{}という中二病心をくすぐる名前のオプションを見つけたw

■ 参考 : Subfigure arrangment with no caption with IEEE format


これを使うとこんな感じの図ができる


blog
\usepackage{subcaption}

\begin{figure}[H]
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\phantomcaption{}
\label{fig:lefttop}
\vspace{4ex}
\end{subfigure}%%
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\phantomcaption{}
\label{fig:righttop}
\vspace{4ex}
\end{subfigure}
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\phantomcaption{}
\label{fig:bottomleft}
\end{subfigure}%%
\begin{subfigure}[]{0.5\linewidth}
\centering
\includegraphics[width=\hsize]{hoge.png}
\phantomcaption{}
\label{fig:bottomright}
\end{subfigure}
\caption{This is an example using subfigure and phantomcaption. This is an example using subfigure and phantomcaption. }
\label{fig:total}
\end{figure}


(参考になったと思ったら ↓の広告クリックしてブログの収益化に貢献オナシャス)









PR
この記事にコメントする
Name
Title
Color
E-Mail
URL
Comment
Password   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
プロフィール
HN:coffee
職業:物理屋(自称)
趣味:映画鑑賞、登山
出身:大阪府の南の田舎
自己紹介:
import MyProfile
import coffee_pote from TWITTER
import amazonのほしい物リスト from WISH_LIST

print "先月子供が産まれました!"

# 最終更新 2022/10/25
カウンター
カウンター カウンター
ブログ内検索
ツイートするボタン
リンク
相互リンク募集中です (Twitterにてお知らせください)

Demo scripts for gnuplot version 5
(gnuplotのさまざまなデモ画像と作り方がまとめられている、眺めているだけでできるようになった気分になれる)

gnuplotスクリプトの解説
(米澤進吾さんの個人ページ、gnuplotと言えばこのかた)

gnuplot のページ
(Takeno Lab、うちのブログがリンクされていたのでリンク返し)

Twitterから映画の評価が分かる & 映画の鑑賞記録が残せる coco
(映画の感想をまとめられるサイト、いつもお世話になっています)

Astronomy Picture of the Day Archive
(天文や宇宙関連の最新の話題について画像とともにNASAが説明しているページ)

今日のほしぞら
(任意の時刻の空で見える星を表示してくれる、国立天文台が管理している)

GNUPLOTとアニメーション
(応用の項目の「見せてあげよう!ラピュタの雷を!!」あたりからすごすぎる)

読書メーター
(読んだ本をリストできる便利なサイト)

flickr難民の写真置き場
(20XX年、flickrは有料化の炎に包まれた。あらゆるflickr無料ユーザーは絶滅したかに見えた。 しかし、tumblr移住民は死に絶えてはいなかった。)

教授でもできるMac OS X へのLaTeX, X11, gccのインストレーションと環境設定
(阪大の山中卓さんのwebページ、タイトルにセンスが溢れている、内容は超充実してる、特にTeX関連、学振DCとかPDの申請書類作成時にはお世話になっております)

英語論文執筆用の例文検索サービス
(とんでもないものを見つけてしまった・・・・ arXivに収録されている 811,761報の 英語論文から,例文を検索するための検索エンジン)


Template "simple02" by Emile*Emilie
忍者ブログ [PR]