So, I'm using the listings package to stylize source code (I'm currently using the solarized colour scheme).
I've set a frame to have a coloured background for the line numbers. I don't want this frame to be shown at the bottom of the code however, I want the border to show (a left and bottom border, but left frame only).
The style code is the following (along with some dummy code from the listings documentation). This is being used for multiple languages, therefore I have omitted the language
selector.
\documentclass[a4paper,11pt]{article}
\usepackage[top=19mm, left=12.925mm, right=12.925mm, bottom=19mm]{geometry}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{xcolor-solarized}
\lstdefinestyle{mystyle}{
basicstyle = \ttfamily\color{solarized-base00}, % -- Making the font monospaced and small
backgroundcolor=\color{solarized-base3}, % -- Setting the background colour to solarized-base3
breaklines=true, % -- Allows automatic line breaking
captionpos=b, % -- Caption position at bottom of listing
commentstyle = \color{solarized-base1}, % -- Sets comments to solarized-green
escapeinside = {\%*}{*}, % -- Useful for adding LaTeX within the code
emphstyle =\bfseries\color{solarized-red}, % -- Emphasized text style to red
frame=l, % -- Adds a line to the left of the listings, which is used for line numbers.
framesep=2em, % -- Frame seperator size
framerule=1pt, % -- Frame line size
fillcolor=\color{solarized-base2}, % -- Frame fill colour
identifierstyle=\color{solarized-base00}, % -- Style for Identifiers
keepspaces=true, % -- Keeps Spaces in text, useful for keeping identation of code.
keywordstyle = \color{solarized-cyan}\bfseries, % -- Keyword style
numbers=left, % -- Line numbers on the left
numbersep=0.5em, % -- How far away should line numbers be from code
numberstyle=\normalfont\footnotesize\color{solarized-violet}, % -- Line Number font style, size and colour
rulecolor=\color{solarized-blue}, % -- if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (solarized-blue here))
showspaces=false, % -- Do not show spaces everywhere by adding particular underscores
showtabs=fase, % -- Do not show tabs within strings adding particular underscores
stringstyle=\color{solarized-blue}, % -- String style
tabsize=2, % -- Setting the tab size to 2 spaces.
xleftmargin=2em % -- Margin from left of listing
}
\begin{document}
\begin{lstlisting}
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case insensitive ’);
WritE(’Pascal keywords.’);
\end{lstlisting}
\end{document}
I have tried searching, and I have tried many different tweaks to my code. Basically, none of these solutions solve the problem I have. If you need more info, please let me know.
Best Answer
It turns out that I am not able to sleep. As promised, here is a version using
tcolorbox
andlistings
.