0

I have c code and i want it to be on a pdf file for nice viewing, I've looked for scripts/programs(for mac/linux) that can do that but I didn't find any. Thanks for your help.

Mike L
  • 1,955
  • 2
  • 16
  • 18

2 Answers2

0

You can use the Listings package in LaTeX. There is a thread about that here.

A hack is to run code prettify in an html document on your computer, and then print your html document to pdf from the browser. Along those lines, you could also run pygments and export to HTML, and then to PDF. Or if you write code with sublimetext, you could use this to export the code directly to HTML: https://github.com/joelpt/sublimetext-print-to-html

Community
  • 1
  • 1
Dave
  • 433
  • 3
  • 9
0

You can use the minted package. The use is as simple as listings.

There is a useful tutorial: https://pt.overleaf.com/learn/latex/Code_Highlighting_with_minted

It is necessary to use -shell-escape when compiling

An advantage that i noticed in the use of minted is the accentuation in the comments, for languages like portuguese. The listings require additional packages and create a series of minor difficulties.