This code is building from the solution posted here.
If this tcolorbox
environment is used within a paragraph, the left gray line disappears...
How do you retain the look of the listing
with the gray line to the left? Thanks.
Here is the code...
\documentclass[a4paper, 10pt, oneside, fleqn, openright]{report}
\usepackage[no-math]{fontspec}
\usepackage{lipsum}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\setotherlanguages{english}
\newcommand{\codeimg}{\includegraphics[scale=0.1]{example-image-a}}
\usepackage{calc}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{pdfpages,graphicx}
\usepackage{mdframed}
\usepackage{listings}
\definecolor{light-gray}{gray}{0.92}
\definecolor{mainColor}{RGB}{211, 47, 47} % some dark red
\renewcommand\lstlistingname{Code}
\lstset{
language=Python,
numbers=left,
numbersep= 7mm,
numberstyle=\color{Black},
stepnumber=1,
tabsize=3,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
basicstyle=\color{Black}\ttfamily,
commentstyle=\color{LimeGreen},
keywordstyle=\color{BurntOrange}\bfseries,
stringstyle=\color{WildStrawberry},
keywords={var, func, extends},
frame=leftline,
framesep=0mm,
xleftmargin=3mm,% marge ajouté à gauche du tableau (à configurer en dernier pour l'alignement global du tableau)
framesep=2mm, %distance texte bord du cadre (limite de la background color)
framerule=0mm,
abovecaptionskip=5mm,
aboveskip=\baselineskip,
belowskip=\baselineskip
}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,listings}
\newtcblisting[use counter=lstlisting]{codeblock}[2][]%
{enhanced,noparskip,breakable,colback=light-gray,
colframe=DarkSlateGray,opacitybacktitle=.8,fonttitle=\bfseries,
before upper={\hspace*{-1em}\raisebox{-3pt}[0pt][0pt]{\includegraphics[height=\baselineskip]{example-image-a}}~#2},
title after break={\centering\footnotesize\itshape\strut\lstlistingname~\thelstlisting~--~continued},
listing only,listing options={xleftmargin=-1mm},
after upper={\centering\strut\lstlistingname~\thelstlisting:~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
frame code={\draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},
#1
}
\begin{document}
\lipsum[1-4]
\par
\begin{codeblock}{Les bases de GDScript}
var nombreDeGardes = 4 #déclaration d'une variable
nombreDeGardes = plusDeux(nombreDeGardes) #appel d'une fonction avec la variable nombreDeGardes passée en paramètre
func maFonction(): #cette ligne déclare une nouvelle fonction nommée maFonction
var variable1 = 7 #nouvelle variable dont la valeur est 7
variable2 = ['un', 'deux', 'trois'] #variable assignée à un tableau contenant trois chaines de caractères
func plusDeux(argument1):
return argument1 + 2
\end{codeblock}
\end{document}
frame code
try withoverlay
– Salim Bou Feb 11 '17 at 6:30tikz
can't calculate the path. – TeXnician Feb 11 '17 at 7:09frame code
withoverlay
and the line appears again. On the second fragment the line also covers part of the continuation title. – Ignasi Feb 11 '17 at 20:12