Some fixes
Well, you were on the right track. You just change \newmint
into \newmintedfile
and, after fixing some settings in your MWE, it will compile with the -shell-escape
option passed to pdflatex
.
The following were the fixes.
- There is no
openright
option for article
class, and hence no chapter
option for minted
as this seems like your settings in your original report
file
- There was a typo in
\inputmined
. It should be \inputminted
.
Explanation of \newmintedfile
The syntax is \newmintedfile[<alias>]{<language>}{<external file>}
.
The usage is the same as that of \newmint
. If you have explicitly specified its alias, say phpcode
then you can use \phpcode{foo.php}
, otherwise, file
is appended to the language name, in this case you write \phpfile{foo.php}
. The documentation was not so good at explaining this but you can find the parallelism with the \newmint
command and their definitions.
The codes
Here is the file foo.php
that I used:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
And here is the foobar.php
file:
<?php
//This is a PHP comment line
/*
This is
a PHP comment
block
*/
?>
And finally the LaTeX code.
\documentclass[preview,border=5]{standalone}
%php syntax highlight
\usepackage[section]{minted}
\definecolor{mintedbackground}{rgb}{0.95,0.95,0.95}
\newmintedfile[phpcode]{php}{
bgcolor=mintedbackground,
fontfamily=tt,
linenos=true,
numberblanklines=true,
numbersep=5pt,
gobble=0,
frame=leftline,
framerule=0.4pt,
framesep=2mm,
funcnamehighlighting=true,
tabsize=4,
obeytabs=false,
mathescape=false
samepage=false, %with this setting you can force the list to appear on the same page
showspaces=false,
showtabs =false,
texcl=false,
}
\usepackage{kantlipsum}
\begin{document}
\phpcode{foo.php}
\kant[1]
\phpcode{foobar.php}
\end{document}
The output
And here is the output
![enter image description here](https://i.stack.imgur.com/ZuUeL.png)
Best Answer
Yes, there is the
\setminted
command for setting options for the whole document. From the package documentation:Setting options only for inline commands can be done via
\setmintedinline
.