
С помощью listing
и minted
и pycon
лексера для эмуляции консоли IPython я хотел бы изменить размер шрифта заголовка на \footnotesize
. К сожалению, мой код ниже не изменяет размер шрифта заголовка "heading", т. е. размер шрифта "Listing 1:" не меняется.
Я не могу использовать пакет caption из-за класса документа 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», набранный более крупным шрифтом):
решение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}