Suggestions for styling Julia/JuMP code in a Latex?

Are there any suggestions around how to best style Julia/JuMP code in Latex?

1 Like

I’ve had good success with minted. It uses pygments, which does support Julia code.

1 Like

Yeah, minted is pretty great.

You might also look at using the @variables and @constraints macros to express a model very compactly, if appropriate.

Minted worked out nicely. Thanks for the tip.

I had some issues with unicode symbols, to the point where I usually change the code to not use them (when putting in documents/slides). Do you have tips / a solution for that?

2 Likes

Note for those using LyX: in LyX 2.3 you can choose to use minted for listings by going to Document > Settings … > Listings and setting the ‘Syntax Highlighting Package’ to ‘Minted’. Now Insert > Program Listing will produce a minted environment. You can right click on it and choose ‘Settings…’, then go to the ‘Advanced’ tab and use ‘language=julia’ (Julia is not yet listed in the dropdown box under ‘Main Settings’).

2 Likes