
Com listing
e minted
e um pycon
lexer para emular um console IPython, gostaria de alterar o tamanho da fonte da legenda para \footnotesize
. Infelizmente, meu código abaixo não altera o tamanho da fonte da legenda "título", ou seja, o tamanho da fonte da "Listagem 1:" não muda.
Não consigo usar o pacote caption por causa da classe de documento 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}
Aqui está o resultado (veja a "Listagem 1" escrita em uma fonte maior):
Responder1
Você pode listing
usar a mesma configuração para a legenda que figure
.
Olhando no listing
pacote encontra-se o caminho:
\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}
Responder2
Maneira não recomendada para este específico documentclass
porque ele lida com as legendas à sua maneira e desta forma quebra essa funcionalidade.
Uma solução possível, já que você realmente não compartilha o que realmente espera como resultado:
\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}