![在带有 tcolorbox 的附录中使用 minted,如何指定代码为单倍行距而文本为双倍行距?](https://linux22.com/image/432861/%E5%9C%A8%E5%B8%A6%E6%9C%89%20tcolorbox%20%E7%9A%84%E9%99%84%E5%BD%95%E4%B8%AD%E4%BD%BF%E7%94%A8%20minted%EF%BC%8C%E5%A6%82%E4%BD%95%E6%8C%87%E5%AE%9A%E4%BB%A3%E7%A0%81%E4%B8%BA%E5%8D%95%E5%80%8D%E8%A1%8C%E8%B7%9D%E8%80%8C%E6%96%87%E6%9C%AC%E4%B8%BA%E5%8F%8C%E5%80%8D%E8%A1%8C%E8%B7%9D%EF%BC%9F.png)
我正在为我的论文写附录,并且正在插入代码,但希望环境minted
中的代码tcolorbox
是单倍行距。
这是我突出显示的代码tex
文件:
%%% ====================================================================
%%% Custom code highlighting using Minted and tikz
%%% ====================================================================
\usepackage{tikz}
%%% ====================================================================
%%% Specific colors used for code highlighting
%%% ====================================================================
\definecolor{matlabcodebg}{rgb}{0.99,0.99,1}
\definecolor{pythoncodebg}{rgb}{0.99,1,0.99}
%\usepackage{minted} % Already charged with tcblibrary minted
\usepackage{tcolorbox}
\tcbuselibrary{minted,skins,breakable,hooks}
\usemintedstyle[python]{default} % Specific color scheme
\usemintedstyle[matlab]{default} % Specific color scheme
%%% ====================================================================
%%% Custom code highlighting using Minted
%%% ====================================================================
% Python footnotesize
\newtcbinputlisting{\pythoninput}[2][]{%
listing file={#2},
minted language=python,
minted style=default,
minted options={
fontsize=\normal,
linenos,
numbersep=1mm,
breaklines=true,
},% <-- put other minted options inside the brackets
overlay={%
\begin{tcbclipinterior}
\fill[gray!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
\end{tcbclipinterior}
},
colback=pythoncodebg,
colframe=black!70,
before skip=5pt plus 2pt,
breakable,
enhanced,% <-- put other tcolorbox options here
listing only,#1
}
在我的附录中,下面是我调用脚本进行格式化的方法:
%%% -*-LaTeX-*-
\documentclass[../Dissertation]{subfiles}
\doublespacing
\begin{document}
\chapter{The Third}
\section{Elastic Moduli}
\subsection{Python Elastic Moduli Curve Fitting}
Python script used to fit a two-term standard linear solid model to creep
data.
\pythoninput{\subfix{Python/LmFit_Example_Lin2020.py}}
\section{Prony Series}
\subsection{Python Prony Series Curve Fitting}
Python script used to fit an n'th-term Prony series model to creep data.
\pythoninput{\subfix{Python/LmFit_Example.py}}
\end{document}
我希望代码块是单倍行距的,但我不确定最好的方法是什么。
谢谢!
答案1
在列表环境中插入以下命令:
code={\singlespacing}