0

I would like to allow minted to break lines after either ., , or a space. Currently I could only break lines either after , or before . How can I allow more characters?

\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}
2

You can use breakafter={<char 1><char 2>...}, and use \space to represent , as mentioned under option breakafter in documentation of package fvextra. Note that breakafter option is defined in fvextra and inherited by 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}

enter image description here

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.