Closed MikeEdu closed 2 years ago
Just had a look into it. I don't see any reason why there shouldn't be an escape sequence for the GenericCode
environment enabled as well. I'll include that for the next iteration after testing it.
For now you can just add it yourself in hgblistings.sty
:
Line 109 needs to be replaced with
escapeinside={/+}{+/},
Thank you!
The reason for not allowing this escape sequence in the GenericCode
environment is that it makes the encapsulated code "non-generic" in the sense that such code may not contain the escape literals themselves ...
Okay, that does make sense, although it's probably a rare case. Let's keep it that way then and I'll adapt this line here
to state that GenericCode
is an exception to this. I will also add a wiki page on how to add this in case this comes up again.
Rare indeed, but needed e.g. to show the sample code for how to use that escape sequence :,-)
As mentioned yesterday, all code environments in hgblistings.sty
accept optional arguments that are forwarded to the underlying \lstset
command. Thus, to use GenericCode
with the usual (or some other) LaTeX escape sequence you can just write, e.g.,
\begin{GenericCode}[escapeinside={/+}{+/}] double alpha = 1.0; /+($\alpha$)+/ double beta = 3.14; /+($\beta$)+/ \end{GenericCode}
Is there any reason, why the GenericCode environment has no escape sequence like
/+ ... +/
?It would be nice, if this feature is also available in the GenericCode environment. Espacially because the escape sequence is mentioned in the tutorial, but it is not mentioned that there is an exception for any code environment.