Where does the additional indentation in the lstlisting environment come from?

I would like to document a function from OpenCV. I used the lstlisting environment from listings package.

\documentclass[12pt]{article}
\usepackage{listings}

\begin{document}

\begin{lstlisting}
double cv::calibrateCamera
(
InputArrayOfArrays  objectPoints,
InputArrayOfArrays  imagePoints,
Size                imageSize,
InputOutputArray    cameraMatrix,
InputOutputArray    distCoeffs,
OutputArrayOfArrays rvecs,
OutputArrayOfArrays tvecs,
int                 flags,
TermCriteria        criteria
)
\end{lstlisting}

\end{document}


The above code was formatted using tabs, as can be seen in the following screenshot that shows them as grey arrows:

As can be seen, the parameter names (that's the second "column": objectPoints, imagePoints, etc.) all line up nicely.

In the result however, additional white space is introduced:

How can I fix this so that the code is rendered verbatim?

As posted the code produces

I would guess your original source has tabs not spaces (this site replaces tabs by spaces)

• The problem was indeed related to tabs. I added an answer. However, given that the MWE is rather useless, given that it doesn't reproduce the problem as you point out, should I delete my question? Or should I edit my question to state that tabs were used for the formatting? – null Oct 25 '16 at 16:34
• no I'd leave it helps other people with same issue (It's possibly a duplicate though I'll look...) – David Carlisle Oct 25 '16 at 16:40

Well, PEBCAC.

If the text should be rendered verbatim, then it must be ensured that tabs are rendered equally.

As it turns out, listings has a few settings, which can be set with this command:

\lstset{
tabsize=4
}


The default value for tabsize is 8 and in my text editor, the size was 4. With the above setting of 4, the code renders just fine.