Latex Macros Cycle Help
Name:Latex Macros Cycle
Version:1.2
Last update:2019-08-15 12:11:23






Introduction

This is a feature for TeX mode, and when it is turned on via the menu item Alpha ↣ TeX Mode Setup ↣ Features two new keyboard shortcuts are defined that allow you to substitute related LaTeX commands for the one surrounding the cursor position, cycling left and right through a list that is presented in the status bar window.
For instance, you can turn successively \SMALL into \Small into \small... Similarly, you can turn the AMS-LaTeX \bigl( into \Bigl( into ... \Biggl(, etc.
By default, the key bindings defined by this package are 'Shift-Option-,' to cycle to the left or 'Shift-Option-.' to cycle to the right. They may be customized as explained in the Changing the cycling bindings section below.
Here are two examples of cycle lists. The following skip macros are grouped in a cycle:
\smallskip \medskip \bigskip
The vertical arrows also constitute a cycling group:
\Downarrow \downarrow \Uparrow \uparrow \Updownarrow \updownarrow
Note that there is no wrapping around: you can only move to the left or move to the right inside a cycle. When you reach the end of a list, a message is displayed in the status bar.
Click here to display the TeX Mode Features Preferences to enable this package in TeX.
This mechanism works with many grouped items in the following submenus of Alpha's LaTeX menu:
Sections
Text Styles
Math Styles
Greek
Theorem
Binary Operators
Relations
Arrows
Dots
Symbols
Functions
Large Operators
Math Accents
Grouping
Spacing
Note that BibTeX mode also implements by default a similar cycling mechanism (which is independent from the present package) for the field names of bibliography entries.

Macros Cycle Usage

When you press one of the cycling key bindings, the package looks for the word surrounding or touching the current cursor position. This word must be a TeX macro, i-e must start with a backslash '\', as in \epsilon. If the macro belongs to a cycling list, then on the first keypress the entire contents of the cycle is displayed in the status bar with the current macro enclosed in a pair of braces. For instance, if the insertion cursor is in the macro \smallskip, then the following is displayed in the status bar:
{smallskip} medskip bigskip
Now if you press again the key binding that moves to the right (by default 'Shift-Option-.'), then the macro \smallskip is replaced by \medskip in the document and the status bar now displays:
smallskip {medskip} bigskip
Press again, then the macro \medskip is replaced by \bigskip in the document and the status bar now displays:
smallskip medskip {bigskip}
You have now reached the end of this cycle and can move to the left with the other key binding (by default 'Shift-Option-,').
If the current position is within a pair of braces {}, as in
\mathbb{This is an |example}
then the subsequent operations take place on the \word preceding the bracketed section (\mathbb in the previous example). This is true even if the cursor and the \word are not on the same line, as in
\textrm{
	Sometimes we do things| like this.
}
If the list is related to size (the original purpose of this package) then the list is presented in the order of magnitude, otherwise related mark-up commands are presented alphabetically. Pressing the key binding again will substitute the next/prev item in the list for the current \word.
Repeated keypresses continue the process. Moving the cursor to another position in your document will reset the procedure, so the next keypress will start all over again, first presenting the list of options appropriate to the new position. You can open the LaTeX Example.tex example file and activate the feature to experiment.
A contextual menu item for TeX mode named Related TeX Commands is also available which operates under the same set of principles.

Changing the cycling bindings

You can adjust these keyboard shortcuts via the preferences Cycle Left and Cycle Right found in the TeX Mode preferences dialog (in the Miscellaneous panel of the mode preferences).

Available cycles

Click here to see the list of grouped keywords that are currently available for cycling.

Creating new cycles

It is easy to create new cycles. Suppose you have defined related TeX macros called \foo, \oof and \baz and want to group them in a cycle. All you have to do is declare a new entry in the TeX::LaTeXCycles array like this:
set TeX::LaTeXCycles(myMacros) {foo oof baz}
Note that the macro names are declared without the backslash. The words may be in any order you reckon is appropriate for your macros (not necessarily alphabetical).
The best location to put this instruction is in the TeXPrefs.tcl file. This file can be opened with the Alpha ↣ Mode Setup ↣ Edit Prefs File menu item when you are in teX mode. Then restart Alpha so that it finds your declaration. Now you will be able to cycle among your \foo, \oof and \baz macros.
In BibTex mode, you should add new cycles of bibliography entry field names to the Bib::CycleEntriesFields.

Known problems

Please report any problem or bug you encounter to Alpha's Bug Tracker.
If you have any other groups to contribute, please contact the package's maintainer or send an e-mail to one of the AlphaTcl mailing lists.

License and Disclaimer

This package was previously named latexSizes (until version 1.1).
Copyright (c) 1997-2019, Vince Darley.
All rights reserved.
The latexMacrosCycle package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL VINCE DARLEY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.