I'm using the listings package to format some source code of a self-invented code language.
In the code, some hierarchical blocks exist, that are defined by keywords. I want to reflect this hierarchy with some formatting using listings if possible
I.e. the code might look like this:
code.vec:
--
command 1
begin include 1
command 2
begin include 2
command 3
end include 2
command 4
end include 1
command 5
--
In the above the block delimiters are: "begin include" and "end include", respectively. When including code.vec in my document (using: \lstinputlisting[language={[mydialect]mylang}]{./code.vec} ), I want the result to look something like this:
Results:
--
command 1
|begin include 1
|command 2
||begin include 2
||command 3
||end include 2
|command 4
|end include 1
command 5
--
Any possibility to do this? The other formatting (syntax highlightning etc.) has to work also in the indented blocks, but I need some way to do the indentation.
Best regards,
Kenneth
I'm using the listings package to format some source code of a self-invented code language.
[...]
In the above the block delimiters are: "begin include" and "end include", respectively. When including code.vec in my document (using: \lstinputlisting[language={[mydialect]mylang}]{./code.vec} ),
moredelim=[s][\ttfamily]{[}{]}
In the above example, the text enclosed by '[' and ']' will be tt'ed - how can I indent it instead?
Does the language inhibit you from indenting the source code to start with? Indentation is usually regarded as A Good Thing in source code.
P
--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/latexusersgroup/-/S6XWEMxjEX8J.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.
Does the language inhibit you from indenting the source code to start with? Indentation is usually regarded as A Good Thing in source code.
P
perl is probably the way to gain ultimate control of the formatting.
indenting may be achieved by an itemize environment, should be possible to make it not print nothing instead of the bullet, something like '\item[]'!?
0le
Send via Android
--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/latexusersgroup/-/eyYJwWW2xngJ.
Have you read the documentation for the listings package? It's pretty dense, but there are some useful hints:
- p.34 the breakindent and breakautoindent; in combination with the \lstinputlisting command, so that if your code is stable, you can list it in selected blocks by line number, using different indentation for some blocks;
- p.50 the \lstdefineformat command, which seems to allow spacing changes according to specific strings