I am pasting some code I have developed for a project from Visual Studio 2019 to LaTeX for a report, however upon pasting the horizontal spacing is far too large and runs off the page. Currently I am using the lstlisting environment:
The LaTeX code is as follows:
\begin{lstlisting}
for (int i = 0; i < numBuses; i++) {
for (int h = 0; h < maxRoute; h++) {
for (int j = 0; j < numStops; j++) {
for (int k = 0; k < numStops; k++) {
if (j == k) {
GRBLinExpr lhs = 0;
lhs += X[i][h][j][k];
basicModel.addConstr(lhs == 0);
}
}
}
}
}
\end{lstlisting}
While i can edit this problem manually the code is hundreds of lines thus this seems impractical. Notice that the spacing become far too large. Could anyone offer any advice on how to fix this problem. Many thanks in advance =)
listings
provides an option to settabsize
. Trytabsize = 2
as part of your options (you can also settab
to something else).