Alpha Q&A #008 |
How to use alpha as an external text editor ? |
Question
How to use Alpha as an external text editor ?
Some applications (such as
Skim,
TeXShop) support
external text editors to perform certain tasks. The following subsections
explain how this feature can be enabled.
Answer
With Skim
Skim is a PDF viewer which
makes synchronization possible between a TeX source file and its pdf output.
You can select Skim as your pdf viewer in Alpha via the Alpha ↣ Global Setup ↣ Helper Applications menu item. Set
the viewPDF service in the PDF panel.
To enable TeX synchronization from Skim, open Skim's preferences, select
the Sync panel and, in the PDF-TeX Sync Support section, choose Alpha.
That's all there is to it: Skim is smart and is able to
automatically find the alphac script
inside Alpha's application bundle.
With TeXShop
TeXShop is a front end
to TeX and LaTeX.
You can select TeXShop as your pdf viewer in Alpha via the Alpha ↣ Global Setup ↣ Helper Applications menu item. Set
the viewPDF service in the PDF panel.
Starting from version 4.24, TeXShop supports TeX synchronization.
It relies for this on a script called othereditor which must be
provided by the text editor: starting from version 9.0.4, Alpha provides
this script. It is distributed with Alpha's ExtraTools (click here to
download the ExtraTools) and is also
found inside the application bundle in Alpha.app/Contents/Resources/Libraries/Extras
(click here
to reveal this directory).
In order to enable this feature, you must perform the following tasks:
- configure TeXShop to use an external editor by selecting the
Configure for External Editor preference found in the Source panel of the
of TeXShop's preferences.
- execute the following command from a Terminal window in order to
enable synchronization with an external editor:
defaults write TeXShop OtherEditorSync YES
This is a TeXShop hidden preference and there is currently no other way to set it.
- copy the othereditor script to the
/usr/local/bin
directory. TexShop's internal mechanism expects this script to be named
exactly like this and to be located in this directory. Assuming that Alpha
is in the /Applications folder, this can be done from a Terminal
window with the following command:
sudo ditto /Applications/Alpha.app/Contents/Resources/Libraries/Extras/othereditor /usr/local/bin/
Alternatively you can make in this directory a soft link called othereditor pointing to the real script. This can be done
from a Terminal window with the following command:
sudo ln -sf /Applications/Alpha.app/Contents/Resources/Libraries/Extras/othereditor /usr/local/bin/othereditor
In both cases, you need admin privileges to do this.
Also make sure that the script has the executable bit set:
sudo chmod a+x /usr/local/bin/othereditor
That's all there is to it. Now, if an error occurs during typesetting, you
may click on the Goto Error button of TeXShop's console to go back
to the source file in Alpha at the line where the error was encountered.
With Terminal
alphac
The alphac script allows Alpha to serve
as the EDITOR
or TEXEDIT
environment variables to open a
file at a given line from the Terminal. In the following instructions, you
must replace $APPLICATION
by the path of the Alpha application as
explained at the beginning of this file.
Setting the environment variable TEXEDIT
in a terminal
window to
$APPLICATION/Contents/Resources/alphac +%d %s
will make the teTeX versions of tex (and pdftex) use Alpha when "e" is
typed at an error prompt.
alphac may also be used as the system editor by setting the EDITOR
environment variable to
$APPLICATION/Contents/Resources/alphac -w
The -w option will make alphac wait until you close the
window of the edited file, letting the system know that you have finished.
See more information on the alphac help
page.
alphaed
In order to quickly edit one or several files with Alpha,
you may use the alphaed command. It is
distributed with Alpha's ExtraTools (click here to download the ExtraTools). The alphaed script
must be found on your PATH
. Then you just have to type something
like:
alphaed somefile
alphaed file1 file2
See more information on the alphaed help
page.
Related Links