I have a long piece of code that highlight with minted
.
I would like to have a background only around a block of code. How can I achieve that?
I tried to use something like escapeinside=||
to create a color box.
In this example we want to put a background to central part, between the \colorbox{green}...
and \end{minipage}}
commands.
\begin{minted}[linenos=true,escapeinside=||,breaklines=true]{cpp}
...
if (is_continuous<T>::value && value.size() == 0)
ar.write(path, static_cast<typename scalar_type<std::vector<T, A> >::type const *>(NULL), std::vector<std::size_t>());
else if (is_continuous<T>::value) {
|\colorbox{green}{\begin{minipage}{\textwidth}|
std::vector<std::size_t> extent(get_extent(value));
std::copy(extent.begin(), extent.end(), std::back_inserter(size));
std::copy(extent.begin(), extent.end(), std::back_inserter(chunk));
std::fill_n(std::back_inserter(offset), extent.size(), 0);
ar.write(path, get_pointer(value), size, chunk, offset);
|\end{minipage}}|
} else if (value.size() == 0)
ar.write(path, static_cast<int const *>(NULL), std::vector<std::size_t>());
else if (is_vectorizable(value)) {
...
\end{minted}
However, this does not compile, I think because the escapeinside
command cannot leave open blocks.
Any idea for achieving the desired behavior?
thanks.
Best Answer
One possible solution (thanks Tom Bombadil) would split the code in more
minted
blocks. However, this also shows some problem. (see below)What I tried is the following code
which results in
Here the problems are:
Is it possible to work around these issues?