1

I'd like to typeset some source code with minted. Unfortunately, a lot this source code runs over 80 columns, some of it up to 132.

What are good settings (and open source fonts?) to use with minted so that I can avoid as much line wrapping as possible?

  • 1
    There's no technical solution to 'my text is too wide': usually this comes up with tables, but it's the same for source code. You'll have to make a human judgement about where line's can be altered. – Joseph Wright May 30 '16 at 8:10
2

I am not sure what the problem actually is ;) since minted does not do line wrapping. So to make 132 columns fit on the page, you'd have to make the font size smaller, that is all. All other settings of minted are not affected and can be changed as needed.

Mathematica graphics

code

\documentclass{article}
\setlength\parindent{0pt}
\usepackage{minted}
\usepackage[margin=1in]{geometry}

\begin{document}

This is my 132 wide code in mint
\scriptsize
\begin{minted}[linenos]{matlab}
function foo()
%this is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog
%comment, 132 long

x=sin(1); %my sinnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn function
end
\end{minted}
\normalsize

This is shorter code

\begin{minted}[linenos]{matlab}
function foo()
%this is not a long comment

x=sin(1); %my sine function
end
\end{minted}
\end{document}

Another option is to make it landscape, and keep the font size normal size, but now it will all fit. Just change the above line to

  \usepackage[landscape,margin=1in]{geometry}

Mathematica graphics

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.