
およびlisting
とIPython コンソールをエミュレートするminted
レクサーを使用しpycon
て、キャプションのフォント サイズを に変更したいと思います\footnotesize
。残念ながら、以下のコードではキャプションの「見出し」のフォント サイズは変更されません。つまり、「リスト 1:」のフォント サイズは変更されません。
IEEEtran ドキュメント クラスのため、キャプション パッケージを使用できません。
\documentclass[journal,12pt,onecolumn,draftclsnofoot,]{ieee_template/IEEEtran/IEEEtran}
\usepackage{listing}
\usepackage[usenames, dvipsnames]{color}
\usepackage{minted}
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\newminted{pycon}{bgcolor=bg, linenos=true, tabsize=4}
\begin{document}
\begin{listing}[]% * for across both columns
\begin{minted}[mathescape, frame=lines, framesep=2mm, fontsize=\footnotesize]{pycon}
In [1]: %run listing_minted_demo.py
Hello World!
x = 3 + 2
\end{minted}
\caption[]{\footnotesize{Example caption. I'd like the caption AND the label Listing 1 to be footnotesize.}}
%\label{mwe}
\end{listing}
\end{document}
答え1
listing
キャプションに と同じ設定を使用することもできますfigure
。
パッケージを見ると、listing
方法が見つかります:
\documentclass[journal,12pt,onecolumn,draftclsnofoot]{IEEEtran}
\usepackage{listing}
\usepackage[usenames, dvipsnames]{color}
\usepackage{minted}
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\newminted{pycon}{bgcolor=bg, linenos=true, tabsize=4}
% let `listing` use the same caption format as figure
\makeatletter
\let\@float@c@listing\@caption
\makeatother
\begin{document}
\begin{listing}[htp]% * for across both columns
\begin{minted}[mathescape, frame=lines, framesep=2mm, fontsize=\footnotesize]{pycon}
In [1]: %run listing_minted_demo.py
Hello World!
x = 3 + 2
\end{minted}
\caption{Example caption. I'd like the caption AND the label Listing 1 to be footnotesize.}
\label{mwe}
\end{listing}
\begin{figure}[htp]
\fbox{\rule{0pt}{3cm}\rule{3cm}{0pt}}
\caption{Example caption}
\end{figure}
\end{document}
答え2
documentclass
この特定の場合、キャプションを独自の方法で処理し、この方法では機能が壊れるため、推奨されない方法です。
実際に出力として期待するものを共有していないため、考えられる解決策は次のとおりです。
\documentclass[journal,12pt,onecolumn,draftclsnofoot,]{IEEEtran}
\usepackage[usenames, dvipsnames]{color}
\usepackage{listing}
\usepackage{minted}
\usepackage{caption}
\captionsetup{font={normalsize}, textfont={sf}, labelfont={bf,sf}}
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\newminted{pycon}{bgcolor=bg, linenos=true, tabsize=4}
\begin{document}
\begin{listing}[]% * for across both columns
\begin{minted}[mathescape, frame=lines, framesep=2mm, fontsize=\footnotesize]{pycon}
In [1]: %run listing_minted_demo.py
Hello World!
x = 3 + 2
\end{minted}
\captionsetup{font={footnotesize}}
\caption[]{\footnotesize Example caption. I'd like the caption AND the label Listing 1 to be footnotesize.}
%\label{mwe}
\end{listing}
\end{document}