Formatting Python code
Paul A. Rubin
parubin73 at gmail.com
Fri May 27 22:24:21 UTC 2022
On 5/27/22 17:39, Rich Shepard wrote:
> On Fri, 27 May 2022, Rich Shepard wrote:
>
>> \lset{language=Python, Tabulator size=4}
>
> Paul,
>
> A more recent thread on program listings
> <ists.lyx.org/pipermail/lyx-users/2022-January/003360.html>
> shows the command as \lstset{} but this also fails to set the default and
> throws an error when I try to compile the document.
>
> Puzzled,
>
> Rich
AFAIK, \lstset{} is the correct command. In order to use it in the
preamble, you have to precede it with
\usepackage{listings}. LyX automatically inserts the use package command
after the preamble, which means the \lstset command is undefined if you
don't manually load the package first. (LyX will still insert another
\usepackage after the preamble, which seems to be harmless.)
The correct syntax for setting the tabulator size is tabsize=4.
"Tabulator size=4" will cause an error.
Setting package defaults in the preamble will not register in the LyX
settings dialog, but they will work. So the dialog will continue to say
"no language" and tab size 4 (or whatever the dialog defaults are), but
your preamble settings will work in the compiled document.
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20220527/474a8275/attachment.html>
More information about the lyx-users
mailing list