TeX - LaTeX Asked by ljk07 on September 1, 2021
With listing
and minted
and a pycon
lexer to emulate an IPython console, I’d like to change the caption font size to be footnotesize
. Unfortunately, my code below does not change the fontsize of the caption “heading” i.e. the fontsize of “Listing 1:” does not change.
I can’t use the caption package because of the IEEEtran document class.
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}
Here’s the output (see “Listing 1” is typeset in a larger font):
Non-recommended way for this specific documentclass
because it handles captions its own way and this way breaks this functionality.
A possible solution since you don't really share what you really expect as output:
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}
Answered by koleygr on September 1, 2021
You can make listing
to use the same setup for the caption as figure
.
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}
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}
Answered by egreg on September 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP