3

I have a minted code listing, displayed in a multicol environment with a separating border between the columns: A minted code listing, displayed in a multicol environment with a separating border. The border is too close to some of the content.

The border is too close to some of the content, like stracka(1,sg,ka). and stracka(3,sg,ka).. What's a good way to fix it?

test.tex:

RequirePackage[l2tabu, orthodox]{nag}
\documentclass[a4paper,12pt,oneside]{scrartcl}
\usepackage{multicol}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}

\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage{microtype}
\usepackage{color}
\usepackage[all]{xy}
\usepackage{minted}
\usepackage{caption}


\setkomafont{disposition}{\normalfont\bfseries}
\renewcommand\listingscaption{Kodlistning}

\begin{document}

\setlength{\columnseprule}{0.5pt}
\begin{multicols}{4}
\inputminted[]{prolog}{someprolog.pl}
\end{multicols}
\label{Blah}
\captionof{listing}{Beskrivande text}

\end{document}

someprolog.pl:

stracka(1,c,sg).
stracka(1,sg,ka).
stracka(1,ka,o).
stracka(1,o,t).

stracka(2,c,sg).
stracka(2,sg,sm).
stracka(2,sm,r).
stracka(2,r,h).

stracka(3,c,sg).
stracka(3,sg,ka).
stracka(3,ka,o).
stracka(3,o,kr).

stracka(4,c,sg).
stracka(4,sg,ka).
stracka(4,ka,o).
stracka(4,o,j).

stracka(5,c,sg).
stracka(5,sg,sm).
stracka(5,sm,r).
stracka(5,r,n).

stracka(6,c,sg).
stracka(6,sg,sm).
stracka(6,sm,r).
stracka(6,r,h).

stracka(7,c,st).
6
  • Welcome to TeX.SX!. Something like \setlength{\columnsep}{5pt} helps? Commented Dec 14, 2013 at 12:29
  • as @karlkoeller says there is a parameter for the column sep (the rule goes down the middle of a gap that wide, but your problem is that the lines are overfull anyway and sticking over their specified margins, so making the gap bigger (and the columns narrower) won't help. You need to decide whether to make the font smaller eg stick \footnotesize somewhere or to allwo line wrapping (I don't know if minted allows that) Commented Dec 14, 2013 at 12:41
  • @DavidCarlisle: Ah. But how do I know that they are overfull? Do you conclude it from the PDF output? I couldn't find a related warning (and to double check latexmk --pdf 2>&1 | grep overfull was blank) when compiling.
    – user42729
    Commented Dec 14, 2013 at 14:01
  • I didn't run it but they clearly are overfull, the final . is touching the rule:-) minted doesn't usually want to play in my cygwin environment, I'll have a try.. Also look in the log file which has more information than the terminal output usually. Your grep is just looking at the latter Commented Dec 14, 2013 at 14:03
  • @DavidCarlisle: You don't have to run it, I was simply trying to learn. :-) As in the past, LaTeX has usually complained when something was overfull. I didn't find any overfull warning in the log file either, but I'll remember to check it in the future! I think minted might be swallowing the complaint. A side note for when Cygwin isn't enough. A cool thing to do is install Ubuntu in a Virtual Box (with Guest Additions) and use "Seamless mode", the result is that you can mix real Linux windows with Windows ones.
    – user42729
    Commented Dec 14, 2013 at 14:16

1 Answer 1

2

I can't get minted to run but just including it as text shows the same thing:

enter image description here

You get warnings about this in the log (not in the terminal output)

Overfull \hbox (15.33626pt too wide) in paragraph at lines 2--2
[]\T1/lmtt/m/n/12 stracka(1,sg,ka).

You need to have less columns or a smaller font or allow linebreaking. Increasing the column sep with \setlength\columnsep{...} without reducing the number of columns will just make things worse as it will make the columns narrower.

\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[a4paper,12pt,oneside]{scrartcl}
\usepackage{multicol}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}


\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage{microtype}
\usepackage{color}
%\usepackage[all]{xy}
%\usepackage{minted}
\usepackage{caption}


\setkomafont{disposition}{\normalfont\bfseries}
%\renewcommand\listingscaption{Kodlistning}

\begin{document}

\setlength{\columnseprule}{0.5pt}
\begin{multicols}{4}
\ttfamily\obeylines\footnot
\input{someprolog.pl}
\end{multicols}
\label{Blah}
\captionof{figure}{Beskrivande text}

\end{document}
1
  • I think minted is swallowing the overfull warning. I don't get it in any of stderr/stdout/log-file. But it's clearly the case, I switched to 3 columns instead of 4.
    – user42729
    Commented Dec 14, 2013 at 14:19

You must log in to answer this question.