0

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 a larger font): enter image description here

  • 2
    Hey and welcome to tex.sx. Your MWE is not compiling well (e.g. you have \usepackages before the \documentclass). Could you fix this? This will make it easier for others to help you. And maybe also specify what exactly you're asking, as this is not clear from your post. – sheß Mar 2 at 13:06
0

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}

enter image description here

  • Why normalsize and not footnotesize as the OP seems to want a footnotesize caption (See the contents of the caption command: 'I'd like the caption AND the label Listing 1 to be footnotesize.' ? – leandriis Mar 2 at 13:26
  • @leandriis I did it for the specific caption... may be (s)he don't want this option to be global across the document and the post doesn't share enough details. This way I give more possible choices to every usage because I used \captionsetup globally but locally too. – koleygr Mar 2 at 13:28
  • I'm sorry, I have overlooked the local definition of the caption's font. Apart from that, combining the caption package and IEEEtran documentclass seems to be discuraged in the documentation ('[...] caption.sty, which, in its default con-figuration, will overrride IEEEtran’s handling of captions — resulting in non-IEEE style main captions' (see page 10)) and also results in a corresponding warning. – leandriis Mar 2 at 13:31
  • @leandriis thanks... I forgot that! You are right... I will add a non-suggested comment on the top of my answer (and a non-suggested documentclass in this comment :P ) – koleygr Mar 2 at 13:33
  • Sorry for the confusion. When I first posted, my explanatory text before the Latex was omitted. Hopefully, what I have added helps. – ljk07 Mar 2 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.