Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm typing up a short comparison of Maple, Mathematica, and Sage in LaTeX. My problem is this: I'd like to include highlighted source code in one column (left) and output in another (right).

I know how to split the view with minipage, and about the listings and minted packages. I've got nice highlighting for Sage by using the python language setting for minted and would like to stick with that package. However, I have not been able to get minted to properly highlight Maple or Mathematica code. Since these two programs are well-known among TeX users, I was thinking that someone might have a solution. It would be nice if I could download the Maple and Mathematica styles.

Otherwise, is there some "best fit" style that I could use for acceptable highlighting?

share|improve this question
    
Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. Also, please add a minimal working example (MWE) that illustrates your problem. This makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. –  Andrew Uzzell Nov 16 '12 at 9:56
add comment

migrated from stackoverflow.com Nov 16 '12 at 9:07

This question came from our site for professional and enthusiast programmers.

1 Answer

Short answer: I'm not aware of a single solution that will do all three languages, at least not without some work on your part. listings will likely be easiest.

minted uses the Pygments syntax highlighter. Pygments currently doesn't support Maple or Mathematica (at least, not unless you can track down someone's custom lexer). So the only way to proceed with minted is probably to write your own lexer (might not be that difficult, but I've never tried).

listings supports Mathematica and Python, but not Maple (but you might look at this). So if you go that route, you will need to define a language (this shouldn't be too difficult; you could start with the link above, and customize to your needs).

Regarding other options: The program highlight can highlight Maple and export a LaTeX version. It also does Python, but not Sage or Mathematica. GNU Source-highlight doesn't have Mathematica or Maple. I've never used either of these. I think that covers all the standard and fallback syntax highlighters (there's also t-vim, but that's for ConTeXt). There are also some language specific options, for example, evidently there's a maple2e package (see this).

You should keep in mind that Sage and Python aren't completely identical (for example, ^ vs. ** for exponents). If you want a more Sage-specific solution, you might see the sagetex package's approach to using Sage with listings. Basically, it defines a new Sage language based on Python, for the Sage console (just search the sagetex documentation for \lstdefinelanguage{Sage}, and take a look at what follows).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.