3 votes

a good python ambient for my latex code

You're doing two things wrong: the code environment of the listings package is not called listing, but lstlisting the \pythonstyle macro should go before the code environment So if you do \...
2 votes
Accepted

How to use \labelformat for lstlisting (with listings package) so that \vref (of varioref package) gives "Listing 1.1 on page x"?

For an unknown reason listing defines its counter only in the begindocument hook. So you must do the change later: \documentclass{book} \usepackage{listings} \usepackage[nospace]{varioref} \AddToHook{...
1 vote
Accepted

Spaces missing in Greek text in listings

See, for instance, https://tex.stackexchange.com/a/25396/4427 You need to add the Greek block U+0370–U+03FF. Possibly also Greek Extended U+1F00–U+1FFF. \documentclass{article} \usepackage[a4paper]{...
  • 1.0m
1 vote

How to add file name to the top-right of a listing environment?

You can use tcolorbox which already comes loaded with many options. Refer to its documentation for more customisation. \documentclass{article} \usepackage[listings,skins]{tcolorbox} \begin{document} ...
  • 575
1 vote
Accepted

How to left-align code in listing package?

Instead of moving the numbers into the text area with numbersep = -6.5pt, you could change the xleftmargin to have the numbers aligned with the surrounding text: \documentclass[aspectratio=169,xcolor =...
1 vote
Accepted

Why does `\pageref` give incorrect page number when a `lstlisting` starts on a new page?

One wonders why this doesn't pop up more often. listings allows the page to break between the \refstepcounter and the caption. Try this after loading listings: \usepackage{etoolbox} \makeatletter \...
1 vote

Pretty displaying code in beamer

For listings to know the keywords, string syntax, number format, comment syntax etc, you need to provide a language identifier. In this case you should add language=Python to \lstdefinestyle{mystyle}. ...
  • 31.7k

Only top scored, non community-wiki answers of a minimum length are eligible