Skip to content

Generate a pdf report of your source code using bash and LaTeX.

License

Notifications You must be signed in to change notification settings

carpsareokiguess/src2pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

src2pdf 📃

Yet another source code to pdf script using LaTeX.

Introduction

Rationale

Ever needed to hand in a hardcopy of the code you produced in a university assignment? Have you almost destroyed your keyboard trying to format a word document (or similar) containing this same source code?

Well look no further, src2pdf is here to put your troubled mind at ease! Using LaTeX and Bash, present your development efforts in a neat and ordered format using one command!

Example

1 2

Show how fancy you are with a title page, table of contents, and syntax highlighting based on source language

How is this script different?

Honestly, this script is not that different to the others out there. However, this implementation does allow you to customise a title, subtitle, author, and source language. If this script gains popularity, I might put in extra features such as fancier title pages.

Installation

Required packages

As this script extensively uses LaTeX, you will need to ensure that it is installed on your system. As an example for Ubuntu, you might install the packages...

$ apt-get install texlive-latex-base texlive-latex-extra

More generally, this script will require the following packages to be installed: pdflatex, color, listings.

Finding the script

After installing the required packages, the script should work out-of-the-box after making it executable. Personally, I like to put the script somewhere where it can be easily found on $PATH (such as /usr/local/bin).

$ chomd +x /usr/local/bin/src2pdf.sh

Operation

Naviagte to your project directory and run the following (assuming the script is on the $PATH):

arosspope@(project) $ src2pdf

You will then be prompted with a series of questions to generate and customise the pdf. Here is an example of the script running:

$ Title (blank to use prm_sim) : PRM Simulator
$ Author (blank for nothing) : arosspope
$ Subtitle (blank for nothing) : A Probabilistic RoadMap (PRM) simulator in ROS
$ Language of files to parse (blank for 'C++') :
$ Provide a space separated list of extensions to include (default is 'h cpp') :
$ Re-order files to place header files in front of source files? (y/n) : y
  Re-ordering files.
$ Review files found? (y/n) : n
  Creating tex file.
  Creating pdf.
...
  Renaming output files.
  Cleaning up.
Done, output file is 'PRM Simulator.pdf' in this directory

Please note that special characters #%$_^&}{)( within the title, subtitle and/or author positions must be escaped, or the script will fail to run.

Currently, the supported languages are specified by the LaTeX source code listings page.

Acknowledgements

The bones of this script comes from the tutorial 'BASH Script to generate PDF of Source Code with Syntax Highlighting using LaTeX' by Sam Hobbs, 2017.

About

Generate a pdf report of your source code using bash and LaTeX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%