用于铸造的多个断线符号

用于铸造的多个断线符号

我想允许 minted 在 或空格后换行.,目前我只能在 之后,或 之前换行. 如何允许更多字符?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{upquote}
\setminted{fontsize=\small, breaklines=true, breakbefore=., breakafter={,}, 
breakbytokenanywhere=true, frame=single, numbers=left, numbersep=5pt, fontfamily=tt}
\begin{document}
\begin{minted}{python}
results = pd.DataFrame(data=results,columns=['Clusters C','Intertia']).set_index('Clusters')
\end{minted}
\end{document}

答案1

您可以使用breakafter={<char 1><char 2>...},并使用\space来表示,如选项breakafter中所述包装文件fvextra。请注意,breakafter选项在中定义fvextra并由其继承minted

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{upquote}
\setminted{
  fontsize=\small, 
  breaklines=true, 
  breakafter={.,\space}, 
  breakbytokenanywhere=true, 
  frame=single, 
  numbers=left, 
  numbersep=5pt, 
  highlightcolor={red!20}, 
  fontfamily=tt
}

\begin{document}
\begin{minted}{python}
# break after .
results = pd.DataFrame(data=results,columns=['Clusters C','Intertia']).set_index('Clusters')
# break after ,
results = pd.DataFrame(data=results,columns=['Clusters C','Intertia','Extra col']).set_index('Clusters')
# break after \space
result_a result_b result_c result_d result_e result_f result_g result_h result_i = some_tuple
\end{minted}
\end{document}

在此处输入图片描述

相关内容