
IPython 콘솔을 에뮬레이션하기 위한 listing
및 어휘 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}