I don't know about mathescape
, but presumably you don't want/need to enter math mode anyway, since you just want to make a box.
So use escapechar=<char>
instead. I've turned your code snippets into an MWE to more clearly show the solution, but the same escapechar=|
(or some other character not used anywhere in the listing) is equally valid inside listing options
in your environment's definition.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\begin{document}
\begin{tcblisting}{listing only,listing options={basicstyle=\ttfamily,escapechar=|}}
Now is the |\fbox{winter}| of our discontent
Made glorious summer by this sun of York;
\end{tcblisting}
\end{document}
Here's the full code made into a compilable example:
\documentclass[11pt]{article}
\usepackage[pdftex]{xcolor}
\definecolor{vlgray}{gray}{0.9}
\definecolor{lgray}{gray}{0.7}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,listings}
\newenvironment{shk}{%
\tcblisting{listing only,colback=vlgray,colframe=vlgray,enlarge
top by=0mm,top=-2mm,bottom=2mm,enhanced,
after={\par\vspace{0.5\baselineskip}\noindent},
overlay={\node[draw,fill= black,yshift=4pt,xshift=-10pt,left,text=white,
anchor=east,font=\footnotesize\bfseries] at (frame.south east)
{Shakespeare};},
listing options={basicstyle=\small\ttfamily,breaklines=true,
language=HTML,escapechar=|},}}
{\endtcblisting}
\begin{document}
\begin{shk}
Now is the |\fbox{winter}| of our discontent
Made glorious summer by this sun of York;
\end{shk}
\end{document}
Something like that?
In my example code, I made a new environment mybox
which takes tcolorbox
options as optional argument, then the title and subtitle text as normal arguments.
The new length settings are done by
my rule=1pt,
left to separator=3cm,
separator to subtitle=1cm,
where my rule
stores the rule width and the two other options store the distances to the vertical line as you requested.
\documentclass{report}
\usepackage{tcolorbox,lipsum}
\tcbuselibrary{skins,raster,breakable}
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
\tcbset{before upper={\setlength{\parindent}{\normalparindent}}}
\tcbset{
my rule/.store in=\myrule,
left to separator/.store in=\mylefttoseparator,
separator to subtitle/.store in=\myseparatortosubtitle,
}
\newtcolorbox{mybox}[3][]{%
my rule=1pt,
left to separator=3cm,
separator to subtitle=1cm,
enhanced,
frame hidden,interior hidden,
sharp corners,
boxrule=\myrule,boxsep=0pt,
left=0pt,right=0pt,top=0.35cm,bottom=0.35cm,
toptitle=0.35cm,bottomtitle=0.35cm,
colframe=black,colback=white,coltitle=black,
borderline north={\myrule}{0pt}{black},
borderline south={\myrule}{0pt}{black},
fonttitle=\bfseries,fontupper=\normalsize,
before skip=0.375cm+2pt,after skip=0.475cm+2pt,
lefttitle=\mylefttoseparator+\myrule+\myseparatortosubtitle,
title={\raggedright\mbox{}#3},
underlay unbroken and first={
\node[right,inner sep=0pt,outer sep=0pt,
font=\large\bfseries,% <-- title font
text width=\mylefttoseparator-5mm] at (title.west) {#2};
\draw[tcbcol@frame,line width=\myrule]
([xshift=-\myrule,yshift=-\myrule/2]title.south west)--([xshift=\myrule,yshift=-\myrule/2]title.south east)
([xshift=\mylefttoseparator+\myrule/2]title.south west)--([xshift=\mylefttoseparator+\myrule/2]title.north west);
},
#1,
}
\begin{document}
\begin{mybox}{TITLE}{SUBTITLE}
\noindent\lipsum[2]
\end{mybox}
\begin{mybox}{TITLE}{Subtitle (If the subtitle is too long, like it is here,
then it should wrap like this, and the title on the left
hand side should be centered relative to the subtitle)}
\noindent\lipsum[3]
\end{mybox}
\end{document}
Best Answer
I'd set the second part outside the
flalign
.