TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got some Fortran 90 source code I want to put into my thesis appendix. For this I'm using the listings package. Is it possible to have colored syntax highlighting for the Fortran code?

share|improve this question
listings should recognise Fortran as one of the known languages: what did you try? – Joseph Wright Nov 8 '11 at 10:51
I found a good solution: use the 'minted' package. This appears to be the best way to auto-color-highlight syntax in code listings. code.google.com/p/minted – Eddy Nov 8 '11 at 11:58
Yeah but it doesn't colour the syntax at all – Eddy Nov 8 '11 at 11:59
You can find minted in the list of my link several alternative packages for syntax highlighting. And there are at least two more packages using the Pygments library: verbments and texments. – Schweinebacke Nov 8 '11 at 12:39
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Jubobs Mar 7 '14 at 10:56
up vote 11 down vote accepted

You have to set the language and the kind of highlighting, e.g.

  morecomment=[l]{!\ }% Comment only with space after !

! Der folgende Fortran-Code ist bei Wikipedia geklaut.
SUBROUTINE test( Argument1, Argument2, Argument3 )
   REAL,              INTENT(IN) :: Argument1
   CHARACTER(LEN= *), INTENT(IN) :: Argument2
   INTEGER,           INTENT(IN), OPTIONAL :: Argument3
   ! This makes sense

For more information about the used settings with \lstset see the manual of listings package.

BTW: There are several alternative packages for syntax highlighting. With fortran there seems to be even a package to print Fortran programs. But I've never used this, it cannot be used for syntax highlighting and was made to be used with plainTeX. So maybe if you want to try an alternative, e.g., highlight would be ab better suggestion.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.