A LaTeX macro for jEdit
Version 19-May-2006.
What is this macro for
jEdit is an impressive free programmer's text editor written in Java.
What is the LaTeX.bsh macro for ? see the screenshots below....
This macro is very similar to the jEdit Clipper and Xinsert plugins. It is expected
to be more convenient because using tabs and icons, the number
of visible commands is much larger, so, all commands can be attained with at most
two mouse clicks.
The present version is designed for use with LaTeX. In particular there is a command panel
for launching latex, pdflatex... If the master document is not indicated
at the end of the file being processed, a dialog window will pop up for
entering (only once) this information.
This macro is divided into two files LaTeX.bsh and LaTeX.js.
All customizations are in the second file. The first file is independent of
the language considered, for example, it can be used for HTML
instead of LaTeX.
Installation
Installing jEdit creates a directory .jedit in the home directory (e.g.
C:\Documents and settings\foo\.jedit or $HOME/.jedit). The installation
of LaTeX.bsh
reduces to unzip the file LaTeX.zip
in the subdirectory macros of .jedit.
In some cases you will have to tune some default paths and names of programs
(latex, pdflatex, bibtex, dvips, dvi viewer, postscript viewer and pdf viewers)
in the file LaTeX.js. See "quick customization" for details.
: recent versions of the console plugin (4.2.6.x) are not working properly. If some commands
of the "command panel" don't work try one of the following tricks:
- Unix: set the shell prefix to "bash" (see Plugins -> Plugins options -> Console -> General -> Shell Prefix).
- Repace the file .jedit/jars/Console.jar by an older version.
- See also the readme.txt file.
Default button panels (Solaris - CDE, Metouia Look and Feel)
All these tabs and buttons can be easily modified (example: sixth panel).
- The button "Link" (fist panel)
opens the Jedit file browser for insertion of images, bib files or other tex files.
- The button "def color" (fist panel) opens the color picker for
defining colors in LaTeX format.
- The button "Mark master doc" (sixth panel) adds in Emacs style the
master document name (avoids definitions of projects).
- The button "Parse doc" (sixth panel) opens a buffer listing all
labels for "copy and paste". The macro behind calls a Perls script, if perl is not
available, remove this button. The LaTeX plugin is more sophisticated but it
parses the document each times a file of the project is saved. I have written
this macro because my computer is very slow, so, I cannot wait for 20 seconds
each times the document is parsed by this plugin.
- The button "Help" (sixth panel) opens this help file in the Info Viewer
(if it disappears immediately, change the "auto hide" feature of the docker plugin).
- The button "Edit macro" (sixth panel) opens a buffer containing the file
LaTeX.js for customization: size and position of the dialog window,
number of tabbed panes, number
of buttons, actions, colors and so on (extension .js in order
to avoid this file to be an entry of the macro menu and in order to preserve colored syntax).
If you change this file, close the dialog and reopen it.
On other platforms
 |
 |
 |
 |
Mac OSX Tabs replaced by a menu: not very convenient |
Windows 2000 |
Windows XP "Look and Feel" with "background color" around buttons |
Linux KDE |
Quick customization (program paths and names)
Click the button "Edit macro" of the sixth screenshot in order to
open the file LaTeX.js. Scroll down to the relevant
area (use find "paths to standard LaTeX commands") and
read the explanations. Briefly:
If you use Windows with MiKTeX
and have installed GSview and AcroRd32 in their
default installation directories (in hard drive "C:"), you have nothing to do
(except tuning the AcroRd32.exe path that depends on its version).
If you use Windows with TeXLive, similar
but change also "isMiktex = true" to "isMiktex = false".
If you use Unix-Linux with the most
standard programs (xdvi, ghostview, acroread, xpdf) you have nothing to do.
If you don't use the most standard programs, you might have to replace
for example
"xdvi" by "kdvi" in xdviString,
"ghostview" by "kghostview" in ghostviewString,
"xpdf" by "gpdf" in pdfString and so on.
Mac, the default paths were defined from a discussion in the
jedit user forum.
The macro distinguishes between LaTeX installation in /sw/bin/ (Fink installation, in this case
change "isFink = false" to "isFink = true") or
in /usr/local/teTeX/bin/powerpc-apple-darwin(6.6). Comments welcome.
There are 8 strings to be adapted depending on your operating system and
LaTeX distribution (in some case, it suffices to comment/uncomment the relevant lines) .
- latexString
- pdflatexString
- bibtexString
- dvipsString
- xdviString
- ghostviewString
- acroreadString
- pdfString
For example, latexString = "latex -interaction nonstopmode -c-style-errors |";
in which "|" will be automatically replaced by the name of the master document.
There is no difficulty to add other commands like "makeindex" for example,
see the next sections.
For launching external programs directly from the command panel the following strings must be
adapted to your system:
- jabrefString
- jpicedtString
- printString
- aspellEnString
Secondary points
The above strings are arguments of a big tridimensional array tabx
that defines all buttons and all actions. Before defining the syntax of the
elements of this array, let us describe some secondary points.
Click the button "Edit macro" of the sixth screenshot in order to
open the file LaTeX.js.
The title of the dialog window (here LaTeX) can be modified in
JDialog frame = new JDialog(view, "LaTeX", false);
You can also modify the size and the location ("right", "left" or
"bottom")
of the dialog window. If you replace the default "tall" shape by a "flat" one,
adapt also nbrow defined below.
int d_width = 150;
int d_height = 450;
String d_position = "right";
The maximum number of panels and of buttons per panel must be defined
(memory reservation), by default the number of panels is limited to 6
and the number of buttons per panel is limited to 70. If necessary
change these values in
JComponent[][] f = new JComponent[6][70];
The number of rows of buttons per panel is 16 by default.
It can be modified in
int nbrow = 16;
The relative path to the icons directory from the directory containing this macro
is imagescol by default. It can be modified in
String path2icons = "imagescol";
Strings appearing on the tabs, see
String[] tabn = {"Gene1","Gene2","Math1","Math2","Greek","Cmds"};
Main customization (definition of buttons and actions)
Syntax of tabx.
Click the button "Edit macro" of the sixth screenshot and scroll down to the
relevant area (use find "commands/clipper panels") and
read the explanations.
Each element tabx[i][j] is an array containing 3 to 5 strings (the indice i corresponds
to tabbed panes, here from 0 to 5, the indice j corresponds to buttons
on each tabbed pane).
- 1st string: "et", "ei", "ct", "ci",
"lt", "li", "st" or "si".
- "e" means empty,
- "c" means clipper command,
- "l" means local command,
- "s" means system command
- "t" means text,
- "i" means icon.
- 2nd string: command that can be "empty" or of "clipper", "local"
or "system" type
- clipper type command example: "{\\bf |}" (| will be replaced by the selected text)
- local type command example: "frame.dispose()"
- system type command example: "dvips -o |.ps |" (| will be
replaced by the master document)
Note that commands are separated in the command string by \n
- 3rd string: "text" (case :"t" in first string)
or "icon name" without its .gif extension (case "i" in first string) to
appear on button
- 4th string: optional, foreground color (case "t") or background color (case "i")
- 5th string: optional, background color (case "t"). Note that depending on
Look and Feel, the background color might be interpreted as the circumference
of the button. Warning: in this case white foreground is not visible.
A few illustrative examples tabx[i][j] =
- {"et","",""}: "e" for empty command (if the second string is
not empty, the corresponding command will be ignored). The button is
replaced by an empty "JLabel".
- {"et","","Slides"}: as above but the "JLabel" is not empty. "t" indicates that this
"JLabel" will contain the text "Slides".
- {"ct","{\\huge |}","Huge"}: "c" indicates that this is a clipper command, i.e.,
the selected text will be replaced by {\huge selected-text} in the active buffer.
If no text is selected, the caret will move to the position of "|".
"t" means that the text "Huge" will appear on the button.
- {"ci","\\alpha","alpha","red"}: "c" for clipper command, here, \alpha
will be written in the active buffer at the caret position,
"i" indicates that the third argument is an icon name, here "alpha.gif"
(icons are stored in the directory "imagescol", customizable). The icon will appear
on a red button.
- {"lt","frame.dispose();","Close","white","black"}: l for local command. Here the local
command is frame.dispose() that closes the dialog window. The text "Close" will
appear in white on a black button.
- {"lt","latexColPick()","def color","red"}. As above but the local command is a user defined
one that must be added in the macro script (scroll down to "User defined actions").
The text "def color" will appear in red.
- {"lt","Macros.getMacro(\"Text/Add_Prefix_and_Suffix\").invoke(view);","Pref & suff","red"}.
As above but here the local command is a macro (Add_Prefix_and_Suffix appearing here in the
macros/Text menu).
- {"st",latexString,"LaTeX"}: "s" for system command. The macro will ask the system
to execute the string latexString (see here) in which
| has been replaced by the master document name.
- {"st","makeindex |","Makeindex"}: as above but here the command string was
not defined earlier.
Comments.
-
Note that the string "|" might appear in some clipper command definitions
like \begin{array}{|c|}. In order to avoid the replacement of "|"
by the buffer selected text, use "\\|" instead of "|"
(e.g. "\\begin{array}{\\|c\\|}").
-
For system commands some shortcuts are very useful.
For example assume that the file of the active buffer is
/home/foo/file.tex:
- $c = file name without extension nor path (e.g., file)
- $d = directory with full path (e.g.,
/home/foo)
- $f = file with extension and full path (e.g., /home/foo/file.tex)
- $n = file name with extension (e.g., file.tex)
- $u = URL for browsers (e.g.,
file://home/foo/file.tex) (don't use because
one slash is missing ("file://" should be "file:///").
For example, if you want to run dvips -o file.ps file the system command strings
are "cd $d" followed by "dvips -o $c.ps $c".
- The commands separator is \n, for example "cd $d \n dvips -o $c.ps $c".
-
For creating new gif icons you can use the script tex2gif.py of
http://www.wag.caltech.edu/home/rpm/projects/tex2gif/
(I used myself an adapted version of this script for batch generation of sets of coloured icons).
Example of ugly customization of the command panel.
Other tools for use with LaTeX
- The "LaTeX plugin" together with the "Sidekick plugin" are very
useful for navigation and for handling labels in large documents.
The "Navigator plugin" is also useful.
-
It is worth
configuring "plugins > plugins options > console > error patterns"
so that LaTeX warnings are sent to the "error list". For example, add
an error pattern (it will only work for warnings on a single line (short labels)).:
Name | LaTeX |
RE | foo |
Warning RE | .*\: (Reference|Citation) \`(.+)\' .+ (\d+)\. |
Extra RE | |
Filename | $f |
Line Numb | $3 |
Err Mess | Warning $1:$2 |
-
For presentations (à la PowerPoint), click the "Tutorial" button beside
the "Beamer" button (first panel). This tutorial is provisional.
-
For BiBTeX data bases management, see
http://jabref.sourceforge.net/
-
For PsTrick figures, see
http://www.jpicedt.org/
History
- 19-May-2006
- Bug of the Perl script used for parsing a project fixed (single documents, i.e., without master document,
were not parsed).
- 15-May-2006
- New macro for navigation within a LaTeX project ("Go to" button of the command panel).
- The Perl script used for parsing a project ("Parse" button of the command panel) has been rewritten
in particular for compatibility with navigation (see above). There are still some limitations
relative to LaTeX code (see the script file latexLabelParser.pl for more information).
- A button for index generation ("Index -s" button of the command panel) has been added. The corresponding
index customization file latexIndex.ist is in the same directory as the main LaTeX.bsh macro.
- More information in the LaTeX.js file for customization of the command panel, minor bugs fixed, etc...
- 22-Dec-2004
- Attempt to define a default configuration for the Mac.
- Modification of the background color of some buttons for compatibility with some "Look and Feel".
- Possibility to define more than one command in the "command strings" (the separator
is \n)
- Document parser slightly improved
- Minor bugs fixed
- 5-Nov-2004: first release.
|