Skip to content

Create latex and pdf file from code project

License

Notifications You must be signed in to change notification settings

Faywyn/code2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code to PDF Converter via LaTeX

This project offers a tool written in TypeScript to convert a folder containing several code files into a PDF document via LaTeX. It provides three npm commands for different actions: generating a .tex file, generating a .pdf file, and a combination of both.

Installation

  1. Make sure Node.js is installed on your system.
  2. Ensure that you have the necessary LaTeX libraries installed (in particular, tcolorbox and its dependencies, which might not be installed by default).
  3. Clone this repository to your machine :
git clone https://github.com/Faywyn/code2pdf
cd code2pdf
npm install

Configuration

Modifiable settings (config.ts)

export const PROJECT_PATH: string = "path/to/project";   // Better if absolut

export const IGNORE_FILES: string[] = [".DS_Store", ".gitignore" /* as exemple */]
export const IGNORE_FOLDERS: string[] = [".git"]

// Link ext to lstlisting valid ones or create yours 
export const EXT_MAP: { [key: string]: string } = {
  "ts": "C",
  "tex": "TEX",
  "c": "C",
  "cpp": "CPP",
  "lua": "[5.0]Lua"
};

// Edit only if needed
export const FILE_TAG: string = "fibzec-0vyhfi-zedJij"

// To edit file format (title, descr, ...), edit tex files in latexFiles/ folder

Usage

  • To generate a .tex file from the code files :
npm run tex
  • To generate a PDF file from the generated .tex file :
npm run pdf
  • To do both at once:
npm run texpdf

The files (.tex and .pdf) will be in the output folder.

Examples

Here’s an example

About

Create latex and pdf file from code project

Topics

Resources

License

Stars

Watchers

Forks