2

I'm trying to highlight certain sections of code in a minted structure, but a certain line just doesn't want to compile with any type of formatting. When I try to use the escape characters and apply any type of formatting (tried colorbox, soul highlighting and bold/italics) to line 8 of the code sample, I get what is shown in the image.

\begin{minted}[
frame=lines,
framesep=2mm,
baselinestretch=1.2,
bgcolor=black,
linenos,
escapeinside=||
]{cpp}
infostream<<"Ban:"<<m_banfilepath;
std::ostringstream ss(std::ios_base);
for(std::map<std::string,std::string>
    ::iterator
        i = m_ips.begin();
        i != m_ips.end(); i++)
{
    |\textbf{ss<<i->first<<"2"<<i->second<<"/n";}|
}
if(!fs::WriteTo(m_banfilepath, ss.str()))
{
    infostream<<"Ban failed:"<<m_banfilepath;
    throw SerializationError("BanM::load()");
}
m_modified = false;
\end{minted}

Screenshot of compiled LaTeX

  • Note that the second answer in the proposed duplicate is the 'official' way, the first answer is similar to your current approach. – Marijn Mar 19 '21 at 22:20
  • @Marijn can I use both methods together, because there's some sections where I want to only highlight a few characters and some where I need whole lines. – Fahim Mohammed Mar 20 '21 at 14:50

0 Answers0