User:Austin J. Che/Extensions/LatexDoc

From OpenWetWare
Jump to navigationJump to search

The LatexDoc extension in MediaWiki SVN has been modified as follows:

  • The biggest change is to allow use of other files on the wiki so that bibtex and graphics works.
  • Requires latexmk
    • The default location for latexmk is in the extensions directory of your mediawiki installation.
    • If you wish to use a different location, add $wgLatexDoc->latexmk = "/path/to/latexmk"; in LocalSettings.php after requiring/including LatexDoc.php.
  • Removed DVI output (not useful on web)
  • Security: Removed filter for "obviously dangerous control words" as it isn't a good security mechanism.
    • Instead, change texmf.cnf so that shell_escape=f, openout_any=p, and openin_any=p. This disallows running system commands and reading or writing any files not under the directory of the tex file.
      • texmf.cnf is located in /usr/share/texmf/web2c/texmf.cnf on tetex distributions. Debian users should edit /etc/texmf/texmf.d/95NonPath.cnf and run update-texmf as root.
    • You may also want to run latex under a chroot jail.
    • If anyone notices any other security issues, please let me know.
  • Added link to get the log file
  • If you want automatic syntax highlighting, install the SyntaxHighlight extension (and GeSHi).

Usage:

Any wiki page that looks like a latex document will automatically have links for added to the top. The Get PDF link will generate a PDF or grab it from the cache if it exists and the Regenerate PDF forces the PDF file to be regenerated.

The special command \usewikifile{Wiki Page Name}{texfilename} can be used. All such commands are stripped before being passed to latexmk for generation of pdf. In addition, the contents of Wiki Page Name are saved as texfilename in the same directory as the page. Thus, you can include graphics or use bibtex where the graphics and .bib file are stored on the wiki. Hint: If you wish to use the same file both on and off the wiki, you can put the \usewikifile in a comment or some other place where normal LaTeX won't parse it (such as after \end{document}). The extension does not care at all the context or the location of the command.

See an example.


Send bugs and comments to Austin Che. Other extensions including sources can be found at User:Austin J. Che/Extensions.