Wednesday, October 12, 2011

Multi-document project in Kile+Okular

This is a continuation of my last post on synctex via kile and okular. In this post I will discuss how to handle multi-project documents while still having synctex facility.

Required scripts

For multi-document project one can do the following: First download the scripts latexmk and the script makelatex2. If the names of the downloaded scripts have extensions, then remove those extensions such that the name of the scripts are ``latexmk" and ``makelatex2". Make the scripts executable and copy them to your $HOME/bin. Create this directory if you don't have it and then log out and login back.

Kile Configuration

Open kile and do the following configuration
Kile > Settings > Configure Kile > Tools > Build 
  New
    Tool Name: makelatex2
    Class: LaTeX
    General:
        Command: makelatex2
        Options: -e- -w- -b- '%source'
    Advanced:
        Type: Run Outside of Kile
        Class: Compile
        Targe extension: pdf
        State: Editor
    Menu:
        Add tool to Build menu: Compile

  Quick Build
    General:
        makelatex2
Now for any sub-documents in the multi-document project include a line
%!TeX root=master.tex
within the first 5 lines. Here master.tex is your main latex file. The makelatex2 script sees the above line and compiles the master.tex file.


Changing the default typesetting command

Default compilation command is pdflatex. However if you want to change the compilation command, then you can do it from the document itself without changing any configuration. Just include the line
%!TeX program=latex+dvipdf
Other compilation commands supported by the makelatex2 script are
pdflatex
    latex
    latex+dvips
    latex+dvipdf
    latex+dvips+ps2pdf
    xelatex
Note that
  • Forward and reverse search however doesn't work with ps file, i.e. with latex+dvips.
  • For multi-document the typesetting comment %!TeX program has to be specified only in the master tex file.

No comments:

Post a Comment