In a LaTeX-X
editor you can compile the edited file using the editor menus. Two
modes of compilation are usable: either the "visualization" mode, or
the "export" mode. The first one compiles the file and visualizes the
result in the format that one chooses (either the PostScript or the PDF
(either with "pdflatex", "latex and ps2pdf" or with "xelatex") - the
visualization of the DVI is, voluntarily, not envisaged), and the
second one compiles and proposes to record the result, with the
possibility of choosing the directory and the name of the file to be
recorded (in latex compilation, the recording of the DVI is possible).
If LaTeX-X has already been launched once (in the same session), when
it is restarted, it tests if the file (or one of its dependencies such
as the bibtex files as well as the inputs) has been modified and then
launches the minimal compilation to update the final result. In other
words, LaTeX-X works in "update" mode, both in "visualization" and
"export". As a result, when the PostScript or PDF viewer is open and
LaTeX-X is restarted, the viewer is not restarted, and an update must
be done. For PostScript visualization, if you use "gv", this can be set
by default in the "gv" options; for viewing PDF, it is better to use
"acroread" but we can use others (xpdf, evince, or put xdg-open and the
system chooses).
The use of LaTeX-X in a LaTeX editor has been tested for
Emacs,
Nedit,
Kile,
Texmaker,
TeXstudio,
LaTeXila
(Gnome LaTeX) and
LyX.
The following documentation indicates, for each publisher, the
procedure to follow. In a general way, the command to be inserted in
the editor is of the following form (ie the command which must be
launched, by the editor, on the edited file: this command must be
followed by something, which depends on the editor, to actually be
launched on the file) :
latex-x --1 -view -editor
for viewing with choice of the format
next
latex-x
--1 -export -editor
to export with choice of format next
latex-x
--1 -view -latex -editor
for a PostScript visualization
latex-x
--1 -view -pdflatex -editor
for PDF viewing with pdflatex
latex-x --1 -view
-pdflatex_pstpdf
-editor
for PDF viewing with pdflatex mode
pst-pdf
latex-x
--1 -view -latex_ps2psf -editor
for viewing the PDF with latex and
ps2pdf
latex-x
--1 -view -xelatex -editor for viewing the PDF with
xelatex
latex-x
--1 -export -latex -editor
to export to
PostScript
latex-x
--1 -export -pdflatex -editor
to export to PDF
with pdflatex
latex-x
--1 -export -pdflatex_pstpdf -editor
to export to PDF
with pdflatex mode
pst-pdf
latex-x --1
-export -latex_ps2pdf -editor
to export to PDF
with latex et
ps2pdf
latex-x
--1 -export -xelatex -editor
to export to en
PDF with
xelatex
The
option -editor tells LaTeX-X to compile into a temporary
directory attached to the chosen editor, and so must match the editor's
name. When leaving the editor, it is strongly
recommended to empty the temporary compilation directories. This can be
done automatically if we run the editor with a
script (for
example, for emacs, put
in $HOME/bin a file "Emacs" containing:
#!/bin/bash (emacs -geometry
115x50+0+0 $@
rm -f -r
$HOME/.latex-x/tmp/latex2gv/emacs rm -f -r
$HOME/.latex-x/tmp/latex2pdf/emacs
rm -f -r
$HOME/.latex-x/tmp/latex2pdf_pst-pdf/emacs
rm -f -r
$HOME/.latex-x/tmp/latex2pdf_ps2pdf/emacs
rm -f -r
$HOME/.latex-x/tmp/xelatex2pdf/emacs)
exit 0
This script starts emacs (on a file or not)
with a certain size of window, and, when we leave emacs, it empties the
temporary compilation directories under emacs (for another editor
replace "emacs" by the name of the emacs editor: nedit,
kile, texmaker, texstudio, lyx). We can also add in
the editor a nenu giving
access to the configuration of LaTeX-X.
To use LaTeX-X
with
Emacs, first install "auctex". We can then put
in Emacs the commands needed to use LaTeX-X, using the emacs
configuration GUI. We go in the group AUC TeX,
then in the group Tex Command, then in Tex Command List, and there we
add the commands that we want by clicking INS at the beginning of the
list.
For example, to add the commands of "visualization"
and
"export" with choice of format :
Name LaTeX-X - View
(update) PostScript or PDF
Command latex-x
'--1' '-view' '-emacs' %t
Name LaTeX-X -
Export to PostScript or PDF
Command latex-x
'--1' '-export' '-emacs' %t
For a direct view command of PostScript, add '-latex' between '-view'and '-emacs', and the same for
pdflatex, vlatex, elatex and pdfelatex, or in export.
Having done that, when you open a LaTeX2e file with emacs,
the LaTeX-X commands are in the "Command" menu of emacs.
To add a command deleting the compilation directories, we add
a new nenu (by clicking on INS, for example after the ones we have just
created) as follows :
Name LaTeX-X -
Clear temporary compilation directories for Emacs
Command rm -f -r
$HOME/.latex-x/tmp/latex2gv/emacs $HOME/.latex-x/tmp/latex2pdf/emacs
$HOME/.latex-x/tmp/latex2pdf_pst-pdf/emacs
$HOME/.latex-x/tmp/latex2pdf_ps2pdf/emacs
$HOME/.latex-x/tmp/xelatex2pdf/emacs
To access LaTeX-X's preferences via an emacs menu we
add the
following menu :
Name LaTeX-X
Preferences
Command latex-x
'--config'
The documentation
given here refers to a version 5.4 or higher of nedit. If it is not this one that is installed on your machine, it
is better to look for this version on the site of nedit and to install
it in its HOME (one finds, on the site, a binary which is small enough (
about 1MB) to be installed). It can also
be useful to install the pack "latex-pack" very well designed for nedit
that can be found on the site nedit.
The
installation of LaTeX-X commands in nedit is then very simple: it is
done in the menu Preferences -> Defaults Settings -> Customize
Menus -> Shell Menu ... This opens a window in which we add the
shell commands for LaTeX -X. As
we have the possibility to make submenus, it is easier to choose the
most complete commands.
For example, to create a
LaTeX-X menu > View (update) of > PostScript, after clicking on
New, enter the following :
In Menu Entry one writes (for example) :
LaTeX-X > Display (Update)
>
PostScript @LaTeX
next check «window» in
Command Input, check
«dialog» in Command Output, check
«Save file before executing command», and, in Shell Command to Execute,
writes
latex-x --1 -view -latex -nedit
% >& /dev/null &
Attention,
the command is typed in csh
because nedit executes the commands shell with this interpreter (this
can theoretically be changed, but the tests that I made did not work
...). @LaTeX means that nenus will only appear
when you open a LaTeX file.
For other commands, we proceed in the same way (being careful
to keep the same names for menus and submenus ie replace "PostScript"
by "PDF pdflatex" and (or) "PDF pdflatex mode pst-pdf" and (or) "PDF latex and ps2pdf" and (or) "PDF xelatex", and
replace "Display (Update)" with "Export to"). The
LaTeX-X commands then appear in sub-menus of Nedit's "Shell" menu when
editing a LaTeX file.
Pour rajouter une commande effaçant le répertoire
temporaire de compilation, on va dans Preferences -> Defaults
Settings -> Customise Menus -> Shell Menu... comme précédemment,
et on rajoute (en cliquant sur New) un nouveau menu :
In Menu Entry writes :
LaTeX-X > Effacer le
répertoire temporaire de compilation
then check «none» in
Command Input, check
«same window» in Command Output, and, in Shell Command to Execute,
writes
rm -f -r
$HOME/.latex-x/tmp/latex2gv/nedit $HOME/.latex-x/tmp/latex2pdf/nedit
$HOME/.latex-x/tmp/latex2pdf_pst-pdf/nedit
$HOME/.latex-x/tmp/latex2pdf_ps2pdf/nedit $HOME/.latex-x/tmp/xlatex2pdf/nedit
To access the preferences of LaTeX-X, proceed as above to add
another nenu :
In Menu Entry writes :
LaTeX-X > LaTeX-X Preferences
then check «none» in
Command Input, check
«dialog» in Command Output, and, in Shell Command to Execute, writes
latex-x --config >&
/dev/null &
For these editors, all you
need to do is set appropriate user commands. These
commands depend on the version used. For
example, with version 1.6 of Kile, to create a PostScript visualization
command, in the User Tools Editor, you type :
Menu elements :
LaTeX-X - PostScript
Visualization
Value :
latex-x --1 -view -latex -kile
%S.tex
For lower versions, replace %S.tex with %.tex (see Kile's
documentation for this).
Use in LyX
A priori, the use of
LaTeX-X in LyX may seem superfluous, since LyX perfectly manages the
compilation in a temporary directory with an update function. There are, however, two reasons that can work in favor of
using LaTeX-X in LyX :
- If
we insert a tex file (with an \ input) into a LyX file and this tex
file itself contains \inputs, when one of the "inputs" of the tex file
is modified, LyX can not know it, and no
compilation update is done, while LaTeX-X sees changes at all levels
(even at the system level for user-modifiable file imputs);
- We
can not simply compile with LyX a file using the pst-pdf package: in
fact, the only way to do this would be to use the ps4pdf script
(provided with pst-pdf), but, if the file to be compiled uses, by
example hyperref, the multiple compilation with ps4pdf
can not produce the final result (it is necessary, after the
precompilation latex, to make at least three compilations pdflatex
WITHOUT reviving latex).
As the use of pst-pdf may be necessary in some cases (use of
pstricks and produce PDF), it seemed useful to use LaTeX-X in LyX.
The easiest way to do this is to edit the preferences file in
the $ HOME directory :
In the section :
#
# FORMATS SECTION ##########################
#
add the following lines (where user is your
username i.e. $HOME=/home/user) :
\format "latexxview" "tex"
"LaTeX-X - View (update) PostScript or PDF" ""
\format "latexxexport" "tex"
"LaTeX-X
- Export to PostScript or PDF" ""
\format "latexxclean" "tex"
"LaTeX-X
- Clean temporary compilation directories for LyX" ""
\format "latexx" "tex" "LaTeX-X
-
Preferences" ""
\viewer
"latexxview" "latex-x --1 -view -lyx"
\viewer "latexxexport" "latex-x
--1
-export -lyx"
\viewer
"latexxclean" "rm -f -r /home/user/.latex-x/tmp/latex2gv/lyx
/home/user/.latex-x/tmp/latex2pdf/lyx
/home/user/.latex-x/tmp/latex2pdf_pst-pdf/lyx
/home/user/.latex-x/tmp/latex2pdf_ps2pdf/lyx
/home/user/.latex-x/tmp/xelatex2pdf/lyx"
\viewer "latexx" "latex-x
--config"
In the section :
#
# CONVERTERS SECTION ##########################
#
add the following lines (where user is your
username i.e. $HOME=/home/user) :
\converter "latex" "latexxview"
"latex-x --1 -view -lyx $$i" ""
\converter "latex"
"latexxexport"
"latex-x --1 -export -lyx $$i" ""
\converter
"latex" "latexxclean" "rm -f -r /home/user/.latex-x/tmp/latex2gv/lyx
/home/user/.latex-x/tmp/latex2pdf/lyx
/home/user/.latex-x/tmp/latex2pdf_pst-pdf/lyx
/home/user/.latex-x/tmp/latex2pdf_ps2pdf/lyx" ""
/home/user/.latex-x/tmp/xelatex2pdf/lyx" ""
\converter "latex" "latexx"
"latex-x --config" ""
In the
"View" menu of LyX, the LaTeX-X commands appear. If
desired, we can also add a button to access these commands. See the LyX doc on this topic (.ui file in the user directory
of LyX).