4

Is there a way to tell minted, that it should highlight the code, without having <?php at the start? I want to highlight my PHP code with minted. But it only highlights, when I use <?php at the start of the code snippet. I don´t want to use the <?php at the start, because I just want to show snippets of the code, not the whole file. It´s a pretty big document, by the following should contain the relevant parts. Minted highlights with the <?php, so I think there is nothing broken on the document site.

\documentclass
\usepackage{minted}
\begin{document}
% This produces highlighted code.
\begin{minted}{php}
    <?php echo "Hello";
\end{minted}
% This won´t.
\begin{minted}{php}
    echo "Hello";
\end{minted}
\end{document}
1
  • 2
    Welcome to TeX.SX! Please post a small complete document (from \documentclass to \end{document}) that shows the issue as well as your settings and packages. Otherwise we have to guess, and the suggested solutions may not work. Moreover, we want to test our solutions before posting them
    – gernot
    Commented Aug 28, 2021 at 16:02

1 Answer 1

6

You can use the startinline option:

\documentclass{article}
\usepackage{minted}
\begin{document}
% This produces highlighted code.
\begin{minted}{php}
    <?php echo "Hello";
\end{minted}
% This won´t.
\begin{minted}[startinline]{php}
    echo "Hello";
\end{minted}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .