Skip to content

This plugin allows to convert articles in Latex to PDF documents.

License

Notifications You must be signed in to change notification settings

GaziYucel/latexConverter

Repository files navigation

Latex to PDF Converter Plugin

The plugin for OJS 3.3, 3.4 and 3.5 that allows to convert articles in Latex to PDF format.

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Contributor Covenant

Features

Extract Archive

Currently only ZIP files are supported.

This functionality is shown if there is an archive file file present in the Production phase.

Clicking this button will do the following:

  • get list of files in archive file
  • present the list to the user in a modal
  • the user selects which file will be the main file
  • the archive file is extracted
    • the selected file will be added as the main file
    • all other files will be added as dependent files

Convert to PDF

This functionality is shown for all files with the extension TEX in the Production phase.

Clicking this button will do the following:

  • copy all files to temp file for processing
  • execute pdflatex from shell
  • check if there is a compiled pdf present:
    • if there is a pdf file
      • add this file the submission
      • add other output files as dependent files (aux, bcf, log, out, run.xml)
    • if there is no pdf file, than something went wrong
      • add the log file to the submission
      • add other output files as dependent files (aux, bcf, out, run.xml)

latexConverter - extract and convert

Install and configure the plugin

Requirements

  • PHP 8.1+
  • A LaTex converter for your platform, e.g. TexLive

Install with Git

Get the correct version for you OJS version:

  • branch main: development version, don't use for production
  • branch stable-3_3_0: use this version for OJS version 3.3.0.x
  • branch stable-3_4_0: use this version for OJS version 3.4.0.x
git clone -b stable-3_4_0 https://github.com/GaziYucel/latexConverter

Install via direct download

  • Download release for your OJS version from https://github.com/TIBHannover/latexConverter/releases. Note the correct version for you OJS version.
  • Alternatively, download the code with the option 'Download ZIP'. Note the correct branch for your OJS version.
  • Extract the downloaded file to ./plugins/generic/latexConverter.

Install TexLive portable (Linux)

# example of installation path: /var/www/TexLive
# TexLive will be installed with all packages and options (around 8GB)
mkdir -p /var/www/TexLive/tmp
cd /var/www/TexLive/tmp
wget -O install-tl-unx.tar.gz https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
mkdir install-tl-unx
tar xf install-tl-unx.tar.gz -C ./install-tl-unx --strip-components=1
cd install-tl-unx
perl install-tl --portable --no-interaction --TEXDIR /var/www/TexLive/texmf --TEXMFLOCAL /var/www/TexLive/texmf-local --TEXMFSYSCONFIG /var/www/TexLive/texmf-config --TEXMFSYSVAR /var/www/TexLive/texmf-var
export PATH=/var/www/TexLive/texmf/bin/x86_64_linux:$PATH
cd /var/www/TexLive
rm -rf tmp

Manual usage of pdflatex

cd /path-to-some-latex-project
/var/www/TexLive/texmf/bin/x86_64-linux/pdflatex -no-shell-escape -interaction=nonstopmode main.tex

Configuration of the plugin

  • Login in your OJS instance as an Administrator or Manager
  • Navigate to Website > Plugins > Installed Plugins > Generic Plugins > LaTex to PDF Converter Plugin > Settings
  • Fill in the absolute path to pdflatex executable, e.g. /var/www/TexLive/texmf/bin/x86_64-linux/pdflatex
  • Fill in the field "Allowed mime types" with mime types which should show dependent files:
    • for TEX files fill in "text/x-tex" and "application/x-tex" on separate lines
    • for TEXT files, fill in "text/plain"
    • for PDF files, fill in "application/pdf"
  • Click Save

latexConverter - settings

Development

  • Fork the repository
  • Make your changes
  • Open a PR with your changes

Structure

.
├── assets                            # Images, styles, scripts
├── classes
│   ├── Handler                       # Handlers
│   ├── Helpers                       # Helper classes
│   ├── Settings                      # Settings classes
│   └── Workflow                      # Classes for the workflow
├── locale                            # Language files
├── templates                         # Templates folder
│   ├── extract.tpl                   # Template for the extract modal
│   └── settings.tpl                  # Settings template
├── vendor                            # Composer autoload and dependencies (ojs 3.3.0)
├── .gitignore                        # Git ignore file
├── composer.json                     # Composer file, e.g. dependencies, classmap (ojs 3.3.0)
├── index.php                         # Main entry point of plugin (ojs 3.3.0)
├── LatexConverterPlugin.php          # Main class of plugin
├── README.md                         # This file
└── version.xml                       # Current version of the plugin

Notes

  • OJS 3.3.0
    • Loading of the classes in the folder classes is done with composer classmap (see below).
    • If you add or remove classes in this folder, run the following command to update the autoload files: composer dump-autoload -o.
    • Running composer install -o or composer update -o will also generate the autoload files
    • The -o option generates the optimised files ready for production.
  • OJS 3.4.0+
    • Loading of classes depends on PSR-4.
    • No composer.json file or vendor directory is needed.

Classmap

You can use the classmap generation support to define loading for all libraries that do not follow PSR-0/4. To configure this you specify all directories or files to search for classes.

Example:

{ 
  "autoload": {
    "classmap": ["src/", "lib/", "Something.php"]
  }
}

You can find more information about classmap here.

About

This plugin allows to convert articles in Latex to PDF documents.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published