画像の最大の高さと最大の幅を同時に定義したいのですが。これを行うためのパッケージがあるはずなのですが、実際には見つけることができません...。
keepaspectratio`キーを使用して、グラフィックを定義することができます。
\includegraphics[width=10cm,height=10cm,keepaspectratio]{image}
MWEは次のようになります。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=2cm,height=3cm,keepaspectratio]{./graphics/amato}
\includegraphics[width=2cm,height=3cm,keepaspectratio]{./graphics/cardtrick}
\end{document}
.
アスペクト比の異なる画像を使って効果を試してみてください。
パッケージ adjustbox
を export
オプションでロードすると、そのキーが includegraphics
で使用可能になります。
\usepackage[export]{adjustbox} % loads also graphicx
をプリアンブルに入れてから
\includegraphics[max height=<dimension>,max width=<dimension]{file}
このようにして、画像は幅と高さが指定された2つの寸法を超えないように最大サイズで拡大され、歪みは生じません。
以下のように、graphicx
パッケージを使用することができます。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{imagefile.pdf}
\caption{Caption of the figure}
\end{figure}
\end{document}
imagefile.pdf
は図のファイル名で、.png, .jpg...... などが使用できます。