home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-09 | 85.1 KB | 2,962 lines |
- #############################################################################
- #############################################################################
- #
- # latexMacros.tcl (called from latex.tcl)
- #
- #############################################################################
- #
- # Author: Tom Scavo (trscavo@syr.edu)
- #
- #############################################################################
- #############################################################################
-
- #############################################################################
- #
- # Basic Commands
- #
- #############################################################################
-
- proc typeset {} {
- global texPath PREFS TeXmodeVars
-
- # Initialization:
- foreach flag {isOzTeX isTextures isCMacTeX isDirectTeX isDirectTeXPro} {
- set $flag 0
- }
- set currentWin [lindex [winNames -f] 0]
- set currentDir [file dirname $currentWin]
- set currentDoc [file tail $currentWin]
- set docBasename [file rootname $currentDoc]
- set docExtension [file extension $currentDoc]
-
- # Is the window untitled or dirty?
- if {[string match $currentWin $currentDoc]} {
- case [askyesno -c "Save \"$currentDoc\"?"] in {
- "yes" {
- if {[catch {set currentWin [saveAs "Untitled\.tex"]}]} then {return}
- }
- "no" {
- if {[regexp {<(.*)>} $currentDoc dummy num]} {
- set tmpFilename "Untitled$num\.tex"
- } else {
- set tmpFilename "Untitled\.tex"
- }
- set text [getText 0 [maxPos]]
- set newDoc "$PREFS:$tmpFilename"
- message "Saving $newDoc..."
- set fd [open $newDoc "w"]
- puts $fd $text
- close $fd
- set currentWin $newDoc
- }
- "cancel" {return}
- }
- } elseif {[winDirty]} {
- case [askyesno -c "Save \"$currentDoc\"?"] in {
- "yes" {save}
- "no" {
- set text [getText 0 [maxPos]]
- set newDoc "$PREFS:temp-$currentDoc"
- message "Saving $newDoc..."
- set fd [open $newDoc "w"]
- puts $fd $text
- close $fd
- set currentWin $newDoc
- }
- "cancel" {return}
- }
- }
-
- # Check if a TeX app is running. If not, open the app named in
- # $texPath (if defined) or have the user select an app via a
- # standard file dialog. Leave the TeX app in the background.
- set appName [checkRunning TeX {OTEX *TEX *XeT MPS* TeX+} texPath 0]
-
- if {[string match {OzTeX*} $appName]} {
- set isOzTeX 1
- } elseif {[string match {Euro-OzTeX*} $appName]} {
- set isOzTeX 1
- } elseif {[string match {Textures*} $appName]} {
- set isTextures 1
- } elseif {[string match {DirectTeX*} $appName]} {
- set isDirectTeXPro 1
- } elseif {[string match {*tex} $appName]} {
- set isCMacTeX 1
- } elseif {[string match {MPW*} $appName]} {
- set isDirectTeX 1
- } else {
- alertnote "Sorry, I don't know how to talk to \"$appName\"."
- return
- }
-
- # Conditionally bring the TeX app to the foreground:
- if {$TeXmodeVars(runTeXInBackground) == 0} { switchTo $appName }
-
- # Typeset the document:
- if {$isOzTeX} {
- sendOpenEvent -n $appName $currentWin
- } elseif {$isTextures} {
- # Choose one of the following three options:
- # dosc -c '*TEX' -s [getText 0 [maxPos]] -r
- # sendOpenEvent -n $appName $currentWin
- dosc -c '*TEX' -f [lindex [winNames -f] 0] -r
- } elseif {$isDirectTeXPro} {
- dosc -c 'TeX+' -s "ProjectMgr -t LaTeX \"$currentWin\"; SelectApp; MenuCommand 1 4"
- } elseif {$isCMacTeX} {
- dosc -n $appName -k 'aevt' -e 'odoc' -r -f $currentWin
- } elseif {$isDirectTeX} {
- set script "Begin; ChangeTeXProject '$currentWin' -check -confirm || Exit 0;\
- Execute \"{dt_TeXProject}\"; TeXMenu -tex -formats; End ╖ Dev:Null;\
- RunSession 1 ╖ Dev:Null"
- dosc -r -n $appName -s $script
- }
- }
-
-
- #--------------------------------------------------------------------------
- # Goto:
- #--------------------------------------------------------------------------
-
- # Switch to (but don't execute) any of the following applications.
- proc latex {} {
- global texPath
- if {![catch {getFileSig $texPath} sig]} {
- set appName [checkRunning TeX $sig texPath]
- } else {
- set appName [checkRunning TeX {OTEX *TEX *XeT MPS* TeX+} texPath]
- }
- if {[string length $appName] > 0} {
- switchTo $appName
- }
- }
- proc bibtex {} {
- global bibtexPath
- set appName [checkRunning BibTeX BIBt bibtexPath]
- if {![string length $appName]} return
- switchTo $appName
- }
- proc makeindex {} {
- global makeindexPath
- set appName [checkRunning MakeIndex Midx makeindexPath]
- if {![string length $appName]} return
- switchTo $appName
- }
-
- # Find the next or previous environment. Search forward (or backward,
- # depending on $forward) for either \begin or \end. If \begin is found,
- # search forward for corresponding \end; otherwise, search backward for
- # corresponding \begin. Select the found environment, or display an
- # error message if no environment is found.
- proc findEnvironment {forward} {
- set searchString1 {^[ \t]*\\begin\{[^\{\}]*\}|\\end\{[^\{\}]*\}[ \t]*\r?}
- set searchPos [getPos]
- if { [isSelection] } then {
- if { $forward } then {
- set searchPos [selEnd]
- } else {
- set searchPos [expr $searchPos - 1]
- }
- } else {
- if { $forward } then {
- set searchPos [expr $searchPos + 1]
- } else {
- set searchPos [expr $searchPos - 1]
- }
- }
- set searchResult [search -s -f $forward -r 1 -n $searchString1 $searchPos]
- if {[string length $searchResult]} then {
- set begPos [lindex $searchResult 0]
- set endPos [lindex $searchResult 1]
- set searchText [getText $begPos $endPos]
- regexp {\{(.*)\}} $searchText dummy envName
- if {[string match {*begin*} $searchText]} {
- set begEnv $begPos
- append searchString2 {\\end\{} $envName {\}[ \t]*\r?}
- set searchPos $endPos
- set searchResult [search -s -f 1 -r 1 -n $searchString2 $searchPos]
- if {[string length $searchResult]} {
- set endPos [lindex $searchResult 1]
- return [list $begPos $endPos]
- } else {
- return "matching \\end not found"
- }
- } else {
- set endEnv $endPos
- append searchString2 {^[ \t]*\\begin\{} $envName {\}}
- set searchPos $begPos
- set searchResult [search -s -f 0 -r 1 -n $searchString2 $searchPos]
- if {[string length $searchResult]} {
- set begPos [lindex $searchResult 0]
- return [list $begPos $endPos]
- } else {
- return "matching \\begin not found"
- }
- }
- } else {
- if { $forward } then {
- return "next environment not found"
- } else {
- return "previous environment not found"
- }
- }
- }
-
- proc prevEnvironment {} {
- global searchNoisily
- set findResult [findEnvironment 0]
- if {[llength $findResult] == 2} then {
- goto [lindex $findResult 0]
- } else {
- if {$searchNoisily} {beep}
- message $findResult
- }
- }
- proc nextEnvironment {} {
- global searchNoisily
- set findResult [findEnvironment 1]
- if {[llength $findResult] == 2} then {
- goto [lindex $findResult 0]
- } else {
- if {$searchNoisily} {beep}
- message $findResult
- }
- }
- proc prevEnvironmentSelect {} {
- global searchNoisily
- set forward 0
- set findResult [findEnvironment $forward]
- if {[llength $findResult] == 2} then {
- set endPos [lindex $findResult 1]
- # if { [regexp {\r} [lookAt [expr $endPos + 1]]] } then {
- # set endPos [expr $endPos + 1]
- # }
- select [lindex $findResult 0] $endPos
- } else {
- if { $searchNoisily } {beep}
- message $findResult
- }
- }
- proc nextEnvironmentSelect {} {
- global searchNoisily
- set forward 1
- set findResult [findEnvironment $forward]
- if {[llength $findResult] == 2} then {
- set endPos [lindex $findResult 1]
- # if { [regexp {\r} [lookAt [expr $endPos + 1]]] } then {
- # set endPos [expr $endPos + 1]
- # }
- select [lindex $findResult 0] $endPos
- } else {
- if { $searchNoisily } {beep}
- message $findResult
- }
- }
-
- # Find a LaTeX command in either direction. It's up to the calling
- # procedure to pass the correct starting position of the search.
- proc findCommand {pos direction} {
- # Handle "\ " and "\[" separately:
- set searchString {(\\([^a-zA-Z\t\r* []|[a-zA-Z]+)\*?)|([^\\]\\\ )|([^\\]\\\[)}
- set searchResult [search -s -f $direction -r 1 -n $searchString $pos]
- if { [string length $searchResult] } {
- set begPos [lindex $searchResult 0]
- set endPos [lindex $searchResult 1]
- set lastChar [lookAt [expr $endPos - 1]]
- if {$lastChar == "\ " || $lastChar == "\["} then {
- return [list [expr $begPos + 1] $endPos]
- } else {}
- }
- return $searchResult
- # Handles everything but "\ " and "\[":
- # set searchString {\\([^a-zA-Z\t\r* []|[a-zA-Z]+)\*?}
- # return [search -s -f $direction -r 1 -n $searchString $pos]
- }
- # Find and goto the beginning of the previous LaTeX command.
- proc prevCommand {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findCommand [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- goto [lindex $searchResult 0]
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "previous command not found"
- }
- # Find and goto the beginning of the next LaTeX command.
- proc nextCommand {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- set searchResult [findCommand [expr $pos + 1] 1]
- if { [string length $searchResult] } {
- goto [lindex $searchResult 0]
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "next command not found"
- }
- # Select the previous LaTeX command, but do not attempt to select
- # any associated argument.
- proc prevCommandSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findCommand [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "previous command not found"
- }
- # Select the next LaTeX command, but do not attempt to select
- # any associated argument.
- proc nextCommandSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findCommand $pos 1]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "next command not found"
- }
-
- # Find a LaTeX command with arguments in either direction. It's up
- # to the calling procedure to pass the starting position of the search.
- # (Handles everything but "\ " and commands whose arguments contain
- # embedded braces.)
- proc findCommandWithArgs {pos direction} {
- set searchString {\\([^a-zA-Z\t\r]|[a-zA-Z]+\*?)(\[.*\])*({[^{}]*})*}
- return [search -s -f $direction -r 1 -n $searchString $pos]
- }
- # Select the previous LaTeX command and any associated arguments.
- proc prevCommandSelectWithArgs {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findCommandWithArgs [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "previous command not found"
- }
- # Select the next LaTeX command and any associated arguments.
- proc nextCommandSelectWithArgs {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findCommandWithArgs $pos 1]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message "next command not found"
- }
-
- # Find a LaTeX sectioning command in either direction. It's up to
- # the calling procedure to pass the starting position of the search.
- proc findSection {pos direction} {
- global funcExprAlt
- return [search -s -f $direction -r 1 -n $funcExprAlt $pos]
- }
- # Select the previous LaTeX sectioning command.
- proc prevSection {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findSection [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {previous section not found}
- }
- # Select the next LaTeX sectioning command.
- proc nextSection {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findSection $pos 1]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {next section not found}
- }
- proc prevSectionSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findSection [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- set begPos [lindex $searchResult 0]
- set searchPos [expr [lindex $searchResult 1] + 1]
- set searchResult [findSection $searchPos 1]
- if { [string length $searchResult] } {
- set endPos [lindex $searchResult 0]
- } else {
- set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
- set endPos [lindex $searchResult 0]
- }
- select $begPos $endPos
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {previous section not found}
- }
- # Select the next LaTeX sectioning command.
- proc nextSectionSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findSection $pos 1]
- if { [string length $searchResult] } {
- set begPos [lindex $searchResult 0]
- set searchPos [expr [lindex $searchResult 1] + 1]
- set searchResult [findSection $searchPos 1]
- if { [string length $searchResult] } {
- set endPos [lindex $searchResult 0]
- } else {
- set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
- set endPos [lindex $searchResult 0]
- }
- select $begPos $endPos
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {next section not found}
- }
-
- # Find a LaTeX subsectioning command in either direction. It's up to
- # the calling procedure to pass the starting position of the search.
- proc findSubsection {pos direction} {
- global funcExpr
- return [search -s -f $direction -r 1 -n $funcExpr $pos]
- }
- proc prevSubsection {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findSubsection [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {previous (sub)*section not found}
- }
- # Select the next LaTeX sectioning command.
- proc nextSubsection {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findSubsection $pos 1]
- if { [string length $searchResult] } {
- eval select $searchResult
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {next (sub)*section not found}
- }
- proc prevSubsectionSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos > 0} then {
- set searchResult [findSubsection [expr $pos - 1] 0]
- if { [string length $searchResult] } {
- set begPos [lindex $searchResult 0]
- set endPos [lindex $searchResult 1]
- set searchPos [expr $endPos + 1]
- set commandName [extractCommandName [getText $begPos $endPos]]
- if {[string match {section*} $commandName]} then {
- set searchResult [findSection $searchPos 1]
- } else {
- set searchResult [findSubsection $searchPos 1]
- }
- if { [string length $searchResult] } {
- set endPos [lindex $searchResult 0]
- } else {
- set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
- set endPos [lindex $searchResult 0]
- }
- select $begPos $endPos
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {previous (sub)*section not found}
- }
- # Select the next LaTeX sectioning command.
- proc nextSubsectionSelect {} {
- global searchNoisily
- set pos [getPos]
- if {$pos < [maxPos]} then {
- if { [isSelection] } then {
- set pos [expr $pos + 1]
- }
- set searchResult [findSubsection $pos 1]
- if { [string length $searchResult] } {
- set begPos [lindex $searchResult 0]
- set endPos [lindex $searchResult 1]
- set searchPos [expr $endPos + 1]
- set commandName [extractCommandName [getText $begPos $endPos]]
- if {[string match {section*} $commandName]} then {
- set searchResult [findSection $searchPos 1]
- } else {
- set searchResult [findSubsection $searchPos 1]
- }
- if { [string length $searchResult] } {
- set endPos [lindex $searchResult 0]
- } else {
- set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
- set endPos [lindex $searchResult 0]
- }
- select $begPos $endPos
- return
- } else {}
- }
- if { $searchNoisily } {beep}
- message {next (sub)*section not found}
- }
-
- proc gotoTabStop {dirIndicator} {
- set pos [getPos]
- if {$dirIndicator} then {
- if {$pos == [maxPos]} {return 0}
- } else {
- if {$pos == 0} {
- set pos [expr $pos - 1]
- return 0
- }
- }
- set searchResult [search -s -n -f $dirIndicator -m 0 -i 1 -r 0 {Ñ} $pos]
- if {[string length $searchResult]} then {
- goto [lindex $searchResult 0]
- return 1
- } else {
- return 0
- }
- }
- proc nextTabStop {} {
- global searchNoisily
- set forward 1
- if {[gotoTabStop $forward]} then {
- deleteChar
- } else {
- if {$searchNoisily} {beep}
- message "tab stop not found"
- }
- }
- proc prevTabStop {} {
- global searchNoisily
- set forward 0
- if {[gotoTabStop $forward]} then {
- deleteChar
- } else {
- if {$searchNoisily} {beep}
- message "tab stop not found"
- }
- }
- # Goto the nth tab stop. A nonzero argument is non-interactive
- # (for use in Tcl procs) and not validated.
- proc nthTabStop {{numTabStops 0}} {
- global searchNoisily promptNoisily useStatusBar
- if {$numTabStops == 0} then {
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "How many tab stops?" "3"} numTabStops
- if {$numTabStops == "cancel" || $numTabStops == 0} then {
- return
- } elseif {![isInteger $numTabStops]} then {
- beep
- message "invalid input"
- return
- }
- }
- set currentPos [getPos]
- if {$numTabStops > 0} {set forward 1} {set forward 0}
- set maxits [expr abs($numTabStops)]
- if {![gotoTabStop $forward]} then {
- if {$searchNoisily} {beep}
- message "tab stop not found"
- goto $currentPos
- return
- }
- for {set i 1} {$i < $maxits} {incr i} {
- if {$forward} {forwardChar} {backwardChar}
- if {![gotoTabStop $forward]} then {
- if {$searchNoisily} {beep}
- message "tab stop not found"
- goto $currentPos
- return
- }
- }
- deleteChar
- }
-
- #--------------------------------------------------------------------------
- # Utilities:
- #--------------------------------------------------------------------------
-
- proc chooseCommand {{men {}} {prompt "LaTeX submenu:"}} {
- watchCursor
- if {![string length $men]} {
- set men [getTeXMenu]
- }
- foreach item $men {
- regsub -all {[<!/].} $item {} item
- regsub -all {╔} $item {} item
- lappend menOut $item
- if {[string match "menu*" $item]} {
- if {[set ind [lsearch $item {-n}]] >= 0} {
- lappend top [lindex $item [incr ind]]
- }
- } elseif {![string match "(*" $item]} {
- lappend top $item
- }
- }
- set res [listpick -p $prompt $top]
- if {[lsearch $menOut $res] >= 0} {
- interpretMenuItem dummy $res
- } else {
- foreach item $menOut {
- if {[set ind [lsearch $item $res]] >= 0} {
- return [chooseCommand [lindex $item end] "LaTeX submenu command:"]
- }
- }
- }
- }
-
- proc insertLiteralTab {} {
- if {[isSelection]} then {
- deleteSelection
- }
- insertText "\t"
- }
-
- proc insertTabStop {} {
- if {[isSelection]} then {
- deleteSelection
- }
- insertText "Ñ"
- }
-
- proc insertReference {} {
- set end [maxPos]
- set pos 0
- set labels {}
-
- set exp {\\label\{(.*)\}}
- while {![catch {search -s -f 1 -r 1 -m 0 -i 0 $exp $pos} res]} {
- set start [lindex $res 0]
- set end [lindex $res 1]
- set text [getText $start $end]
- regexp {\{(.*)\}} $text dummy label
- lappend labels $label
- set pos [expr $end +1]
- }
-
- set ref [listpick -p "Select a reference to insert" [lsort $labels]]
- if {[string length $ref]} {
- insertText "\\ref\{$ref\}"
- }
- }
-
- # Removes all tab stops from the current selection (if there is one)
- # or the current document, maintaining the cursor position in the
- # latter case.
- proc deleteTabStops {} {
- global searchNoisily
- watchCursor
- set subs1 0; set subs2 0; set subs3 0
- set pos [getPos]
- if {[set start $pos] == [set end [selEnd]]} {
- set messageString "document"
- set start 0
- set end [maxPos]
- set text1 [getText $start $pos]
- set subs1 [regsub -all {Ñ} $text1 {} text1]
- set text2 [getText $pos $end]
- set subs2 [regsub -all {Ñ} $text2 {} text2]
- append text $text1 $text2
- } else {
- set messageString "selection"
- set text [getText $start $end]
- set subs3 [regsub -all {Ñ} $text {} text]
- }
- if {$subs1 || $subs2 || $subs3} then {
- replaceText $start $end $text
- if {$messageString == "document"} then {
- goto [expr $pos - $subs1]
- } else {
- set end [getPos]
- select $start $end
- }
- set subs [expr $subs1 + $subs2 + $subs3]
- message "$subs tab stops removed from $messageString"
- } else {
- if {$searchNoisily} {beep}
- message "no tab stops found in $messageString"
- }
- }
-
- # Delete all unnecessary comments from the current document:
- proc deleteComments {} {
- case [askyesno "Warning! This operation can not be undone. \
- Continue anyway?"] in {
- "yes" {}
- "no" { return }
- }
- replaceString {}
- eval select [search -f 1 -r 1 -i 1 -m 0 -- {^[ \t]*%.*\r} 0]
- replaceAll
-
- replaceString {}
- eval select [search -f 1 -r 1 -i 1 -m 0 -- {[ \t]+%.*} 0]
- replaceAll
-
- replaceString {\1%}
- eval select [search -f 1 -r 1 -i 1 -m 0 -- {([^\\](\\\\)*)%.*} 0]
- replaceAll
- }
-
- # Converts all straight quotes to their TeX equivalents.
- proc convertQuotes {} {
- global searchNoisily
- message "working╔"
- watchCursor
- set messageString "selection"
- if {[set start [getPos]] == [set end [selEnd]]} {
- set messageString "document"
- set start 0
- set end [maxPos]
- }
- set text [getText $start $end]
- # Convert all left double quotes:
- set convert1 [regsub -all "\(\^\|\[\ \r\t\(\[\{\]\)\"" $text {\1``} text]
- # Convert all right double quotes:
- set convert2 [regsub -all "\(\[\^\\\\\]\)\"" $text {\1''} text]
- # Convert all left single quotes:
- set convert3 [regsub -all "\(\^\|\[\ \r\t\(\[\{\]\)\'" $text {\1`} text]
- if {$convert1 || $convert2 || $convert3} then {
- replaceText $start $end $text
- message "all quotes in $messageString converted"
- } else {
- if {$searchNoisily} {beep}
- message "no quotes found in $messageString"
- }
- }
-
- # Returns true if the argument contains non-literal double dollar
- # signs, and false otherwise.
- proc containsDoubleDollarSigns {text} {
- return [regexp {(^|[^\\])\$\$} $text]
- }
-
- # Converts all $$...$$ pairs to \[...\] and returns the number of such
- # pairs converted. If the dollar signs are unbalanced, does nothing
- # and returns -1.
- proc convertDoubleDollarSigns {} {
- watchCursor
- set messageString "selection"
- if {[set start [getPos]] == [set end [selEnd]]} {
- set messageString "document"
- set start 0
- set end [maxPos]
- }
- set text [getText $start $end]
- set subs [regsub -all {(^|[^\\])\$\$([^$]*)\$\$} $text {\1\\[\2\\]} text]
- if {[containsDoubleDollarSigns $text]} then {return -1}
- if {$subs} then {
- replaceText $start $end $text
- }
- return [expr $subs]
- }
-
- # Returns true if the argument contains a non-literal dollar sign,
- # and false otherwise.
- proc containsSingleDollarSign {text} {
- return [regexp {(^|[^\\])\$} $text]
- }
-
- # Converts all $...$ pairs to \(...\), maintains the cursor position,
- # and returns the number of such pairs converted. If the dollar signs
- # are unbalanced, does nothing and returns -1.
- proc convertSingleDollarSigns {} {
- watchCursor
- set subs1 0; set subs2 0; set subs3 0
- set pos [getPos]; set pos2 $pos
- if {[set start $pos] == [set end [selEnd]]} {
- set isSelection 0
- set start 0
- set end [maxPos]
- set text1 [getText $start $pos]
- set subs1 [regsub -all {(^|[^\\])\$([^$]*)\$} $text1 {\1\\(\2\\)} text1]
- # Is there a dollar sign left over? If so, search backward for this
- # dollar sign and prepare to do a substitution on the text to the right
- # of this dollar sign.
- if {[containsSingleDollarSign $text1]} then {
- set searchString {[^\\]\$}
- set searchResult [search -s -n -f 0 -m 0 -i 1 -r 1 $searchString [expr $pos-1]]
- set pos2 [lindex $searchResult 0]
- set text1 [string range $text1 0 [expr $pos2 + (2 * $subs1)]]
- set pos [expr $pos + 2]
- }
- set text2 [getText $pos2 $end]
- set subs2 [regsub -all {(^|[^\\])\$([^$]*)\$} $text2 {\1\\(\2\\)} text2]
- # Is there a dollar sign left over? If so, it's unbalanced.
- if {[containsSingleDollarSign $text2]} then {return -1}
- append text $text1 $text2
- } else {
- set isSelection 1
- set text [getText $start $end]
- set subs3 [regsub -all {(^|[^\\])\$([^$]*)\$} $text {\1\\(\2\\)} text]
- # Is there a dollar sign left over? If so, it's unbalanced.
- if {[containsSingleDollarSign $text]} then {return -1}
- }
- if {$subs1 || $subs2 || $subs3} then {
- replaceText $start $end $text
- # If there is a selection, just put it back. Otherwise, adjust the
- # cursor position based on the number of substitutions.
- if {$isSelection} then {
- set end [getPos]
- select $start $end
- } else {
- goto [expr $pos + (2 * $subs1)]
- }
- }
- return [expr $subs1 + $subs2 + $subs3]
- }
-
- proc convertDollarSigns {} {
- global searchNoisily
- if {[isSelection]} then {
- set messageString "selection"
- } else {
- set messageString "document"
- }
- set subs2 [convertDoubleDollarSigns]
- if {$subs2 == -1} then {
- beep
- alertnote "unmatched double dollar signs in $messageString"
- } else {
- set subs1 [convertSingleDollarSigns]
- if {$subs1 == -1} then {
- beep
- alertnote "unmatched single dollar sign in $messageString"
- } elseif {$subs1 == 0 && $subs2 == 0} then {
- if {$searchNoisily} {beep}
- message "no dollar signs found in $messageString"
- } else {
- message "$subs1 pairs of \$...\$ and $subs2 pairs of \$\$...\$\$ removed from $messageString"
- }
- }
- }
-
- proc removeAuxiliaryFiles {} {
- set word ""
- set currentWin [lindex [winNames -f] 0]
- set currentDir [file dirname $currentWin]
- set currentDoc [file tail $currentWin]
- set docBasename [file rootname $currentDoc]
- set docExtension [file extension $currentDoc]
- set extensions {.aux .bbl .dvi .glo .idx .ind .lof .log .lot \
- .toc .blg .clg .ilg .ps}
- foreach ext $extensions {
- if {[file exists "$currentDir:$docBasename$ext"]} then {
- set word " more"
- case [askyesno -c "Remove \"$docBasename$ext\"?"] in {
- "yes" {
- if {[catch {rm "$currentDir:$docBasename$ext"}]} then {
- alertnote "\"$docBasename$ext\" not deleted"
- }
- }
- "no" {}
- "cancel" {return}
- }
- }
- }
- message "no$word files found"
- }
-
-
- #############################################################################
- #
- # Paragraph Mode Macros
- #
- #############################################################################
-
- #--------------------------------------------------------------------------
- # Documents:
- #--------------------------------------------------------------------------
-
- proc letter {} {
- set preamble "\r\\address\{%\r"
- append preamble " Ñ \\\\ % insert your name here\r"
- append preamble " Ñ \\\\ % insert your address here\r"
- append preamble " Ñ \\\\ % insert more address here\r"
- append preamble " Ñ % insert city-state-zip here\r"
- append preamble "\}\r\r"
- append preamble "\\date\{Ñ\} % optional\r"
- append preamble "\\signature\{Ñ\}\r\r"
- set body "\r\\begin\{letter\}\{%\r"
- append body " Ñ \\\\ % insert addressee's name here\r"
- append body " Ñ \\\\ % insert addressee's address here\r"
- append body " Ñ \\\\ % insert more address here\r"
- append body " Ñ % insert addressee's city-state-zip here\r"
- append body "\}\r\r"
- append body "\\opening\{Dear Ñ,\}\r\r"
- if {[isEmptyFile]} then {
- append body "% BODY OF LETTER\r"
- append body "Ñ\r\r"
- } else {
- if {[isDocumentSelected]} then {
- set text [getSelect]
- # deleteText 0 [maxPos]
- append body "$text\r"
- } else {
- alertnote "nonempty file: delete text or \'Select All\'\
- from the Edit menu"
- return
- }
- }
- append body "\\closing\{Sincerely,\}\r\r"
- append body "\\encl\{Ñ\}\r"
- append body "\\cc\{Ñ\}\r\r"
- append body "\\end\{letter\}\r\r"
- insertDocument "letter" $preamble $body
- nextTabStop
- message "enter option (or leave blank)"
- }
- proc article {} {
- wrapDocument "article"
- }
- proc report {} {
- wrapDocument "report"
- }
- proc book {} {
- wrapDocument "book"
- }
- proc slides {} {
- wrapDocument "slides"
- }
- proc custom {} {
- catch {prompt "What documentclass?" "article"} documentType
- if {$documentType != "cancel"} then {
- wrapDocument "$documentType"
- }
- }
-
- proc getOption {} {
- catch {prompt "Choose an option:" "11pt" "" "10pt" "11pt" "12pt" "(-" \
- "letterpaper" "legalpaper" "executivepaper" "a4paper" "a5paper" \
- "b5paper" "(-" "landscape" "(-" "final" "draft" "(-" \
- "oneside" "twoside" "(-" "openright" "openany" "(-" \
- "onecolumn" "twocolumn" "(-" "notitlepage" "titlepage" \
- "openbib" "(-" "leqno" "(-" "fleqn"} optionName
- if {$optionName != "cancel"} then {
- return $optionName
- } else {
- return ""
- }
- }
- proc insertOption {option} {
- global searchNoisily
- set searchString {\\documentclass}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
- if {[llength $searchResult] == 0} then {
- if {$searchNoisily} {beep}
- message "can\'t find \\documentclass"
- } else {
- set nextCharPos [lindex $searchResult 1]
- goto $nextCharPos
- set nextChar [lookAt $nextCharPos]
- if {$nextChar == "\["} then {
- forwardChar
- insertText $option
- if {[lookAt [getPos]] != "\]"} then {
- insertText ","
- }
- } elseif {$nextChar == "\{"} then {
- insertText "\[$option\]"
- } else {
- alertnote "unrecognizable \\documentclass statement"
- }
- }
- }
- proc options {} {
- set option [getOption]
- if {$option != ""} then {
- insertOption $option
- }
- }
- proc getPackage {} {
- catch {prompt "Choose a package:" "latexsym" "" \
- "alltt" "amstex" "babel" "color" \
- "graphics" "graphpap" "ifthen" "latexsym" "makeidx" \
- "pict2e" "showidx"} packageName
- if {$packageName != "cancel"} then {
- return $packageName
- } else {
- return ""
- }
- }
- proc insertPackage {package} {
- global searchNoisily
- set begPos [getPos]
- set endPos [selEnd]
- append searchString {\\usepackage\{.*} $package {.*\}}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
- if {[llength $searchResult] == 0} then {
- set searchString {\\documentclass(\[.*\])?\{.*\}}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
- if {[llength $searchResult] == 0} then {
- if {$searchNoisily} {beep}
- message "can't find \\documentclass"
- } else {
- goto [lindex $searchResult 1]
- set txt "\r\\usepackage\{$package\}"
- set offset [string length $txt]
- set begPos [expr $begPos + $offset]
- set endPos [expr $endPos + $offset]
- insertText $txt
- select $begPos $endPos
- }
- } else {
- if {$searchNoisily} {beep}
- message "$package package already loaded"
- }
- }
- proc packages {} {
- set package [getPackage]
- if {$package != ""} then {
- insertPackage $package
- }
- }
- proc filecontents {} {
- global searchNoisily
- set searchString {\\documentclass}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
- if {[llength $searchResult] == 0} then {
- if {$searchNoisily} {beep}
- message "can\'t find \\documentclass"
- return
- } else {
- set prompt "File to be included:"
- if {[catch {getfile $prompt} path]} then {
- return
- } else {
- set fd [open $path]
- set text [read $fd]
- close $fd
- regsub -all "\xa" $text "\xd" text
- goto 0
- set envName "filecontents"
- set envArg "{[file tail $path]}"
- replaceText 0 0 [buildEnvironment $envName $envArg "$text\r" "\r\r"]
- goto 0
- message "file included"
- }
- }
- }
-
- #--------------------------------------------------------------------------
- # Page Layout:
- #--------------------------------------------------------------------------
-
- proc maketitle {} {
- global searchNoisily
- set searchString {\\document(class|style)(\[.*\])?\{.*\}}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
- if {[llength $searchResult] == 0} then {
- if {$searchNoisily} {beep}
- message "can\'t find \\documentclass or \\documentstyle"
- } else {
- set searchPos [lindex $searchResult 1]
- set searchString {\\begin\{document\}}
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString $searchPos]
- if {[llength $searchResult] == 0} then {
- if {$searchNoisily} {beep}
- message "can\'t find \\begin\{document\}"
- } else {
- goto [lindex $searchResult 1]
- set currentPos [getPos]
- set txt "\r\r% Definition of title page:"
- append txt "\r\\title\{"
- append txt "\r\tÑ\r\}"
- append txt "\r\\author\{"
- append txt "\r\tÑ\t% insert author(s) here"
- append txt "\r\}"
- append txt "\r\\date\{Ñ\}\t% optional"
- append txt "\r\r\\maketitle"
- insertText $txt
- goto $currentPos
- nextTabStop
- message "insert title"
- }
- }
- }
- proc abstract {} { doWrapEnvironment "abstract" }
- proc titlepage {} { doWrapEnvironment "titlepage" }
- proc getPagestyle {} {
- catch {prompt "Choose a pagestyle:" "plain" "" "plain" "empty" \
- "headings" "myheadings"} pagestyleName
- if {$pagestyleName != "cancel"} then {
- return $pagestyleName
- } else {
- return ""
- }
- }
- proc pagestyle {} {
- set pagestyleName [getPagestyle]
- if {$pagestyleName != ""} then {
- openingCarriageReturn
- insertObject "\\pagestyle\{$pagestyleName\}"
- closingCarriageReturn
- }
- }
- proc thispagestyle {} {
- set pagestyleName [getPagestyle]
- if {$pagestyleName != ""} then {
- openingCarriageReturn
- insertObject "\\thispagestyle\{$pagestyleName\}"
- closingCarriageReturn
- }
- }
- proc getPagenumberingStyle {} {
- catch {prompt "Choose a pagenumbering style:" "arabic" "" "arabic" \
- "roman" "Roman" "alph" "Alph"} pagenumberingStyle
- if {$pagenumberingStyle != "cancel"} then {
- return $pagenumberingStyle
- } else {
- return ""
- }
- }
- proc pagenumbering {} {
- set pagenumberingStyle [getPagenumberingStyle]
- if {$pagenumberingStyle != ""} then {
- openingCarriageReturn
- insertObject "\\pagenumbering\{$pagenumberingStyle\}"
- closingCarriageReturn
- }
- }
- proc twocolumn {} {
- openingCarriageReturn
- insertObject "\\twocolumn"
- closingCarriageReturn
- }
- proc onecolumn {} {
- openingCarriageReturn
- insertObject "\\onecolumn"
- closingCarriageReturn
- }
-
- #--------------------------------------------------------------------------
- # Sectioning:
- #--------------------------------------------------------------------------
-
- proc part {} {
- if {[wrapObject "\\part{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the part name and don't forget the label"
- }
- }
- proc chapter {} {
- if {[wrapObject "\\chapter{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the chapter name and don't forget the label"
- }
- }
- proc section {} {
- if {[wrapObject "\\section{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the section name and don't forget the label"
- }
- }
- proc subsection {} {
- if {[wrapObject "\\subsection{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the subsection name and don't forget the label"
- }
- }
- proc subsubsection {} {
- if {[wrapObject "\\subsubsection{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the subsubsection name and don't forget the label"
- }
- }
- proc paragraph {} {
- if {[wrapObject "\\paragraph{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the paragraph name and don't forget the label"
- }
- }
- proc subparagraph {} {
- if {[wrapObject "\\subparagraph{" "}Ñ"]} then {
- message "don't forget the label"
- } else {
- message "type the subparagraph name and don't forget the label"
- }
- }
- proc appendix {} {insertObject "\\appendix"}
-
- #--------------------------------------------------------------------------
- # Text Style:
- #--------------------------------------------------------------------------
-
- proc emph {} {
- if {[wrapObject "\\emph{" "}Ñ"]} then {
- message "selected text has been emphasized"
- } else {
- message "enter text to be emphasized"
- }
- }
- proc textup {} {
- if {[wrapObject "\\textup{" "}Ñ"]} then {
- message "selected text has upright shape"
- } else {
- message "enter text to have upright shape"
- }
- }
- proc textit {} {
- if {[wrapObject "\\textit{" "}Ñ"]} then {
- message "selected text has italic shape"
- } else {
- message "enter text to have italic shape"
- }
- }
- proc textsl {} {
- if {[wrapObject "\\textsl{" "}Ñ"]} then {
- message "selected text has slanted shape"
- } else {
- message "enter text to have slanted shape"
- }
- }
- proc textsc {} {
- if {[wrapObject "\\textsc{" "}Ñ"]} then {
- message "selected text has small caps shape"
- } else {
- message "enter text to have small caps shape"
- }
- }
- proc textmd {} {
- if {[wrapObject "\\textmd{" "}Ñ"]} then {
- message "selected text has been set in medium series"
- } else {
- message "enter text to be set in medium series"
- }
- }
- proc textbf {} {
- if {[wrapObject "\\textbf{" "}Ñ"]} then {
- message "selected text has been set in bold series"
- } else {
- message "enter text to be set in bold series"
- }
- }
- proc textrm {} {
- if {[wrapObject "\\textrm{" "}Ñ"]} then {
- message "selected text has been set with roman family"
- } else {
- message "enter text to be set using roman family"
- }
- }
- proc textsf {} {
- if {[wrapObject "\\textsf{" "}Ñ"]} then {
- message "selected text has been set with sans serif family"
- } else {
- message "enter text to be set using sans serif family"
- }
- }
- proc texttt {} {
- if {[wrapObject "\\texttt{" "}Ñ"]} then {
- message "selected text has been set with typewriter family"
- } else {
- message "enter text to be set using typewriter family"
- }
- }
- proc textnormal {} {
- if {[wrapObject "\\textnormal{" "}Ñ"]} then {
- message "selected text has been set with normal style"
- } else {
- message "enter text to be set using normal style"
- }
- }
-
- #--------------------------------------------------------------------------
- # Text Size:
- #--------------------------------------------------------------------------
-
- proc tiny {} {
- if {[wrapObject "{\\tiny " "}Ñ"]} then {
- message "tiny text set"
- } else {
- message "enter tiny text"
- }
- }
- proc scriptsize {} {
- if {[wrapObject "{\\scriptsize " "}Ñ"]} then {
- message "scriptsize text set"
- } else {
- message "enter scriptsize text"
- }
- }
- proc footnotesize {} {
- if {[wrapObject "{\\footnotesize " "}Ñ"]} then {
- message "footnotesize text set"
- } else {
- message "enter footnotesize text"
- }
- }
- proc small {} {
- if {[wrapObject "{\\small " "}Ñ"]} then {
- message "small text set"
- } else {
- message "enter small text"
- }
- }
- proc normalsize {} {
- if {[wrapObject "{\\normalsize " "}Ñ"]} then {
- message "normalsize text set"
- } else {
- message "enter normalsize text"
- }
- }
- proc large {} {
- if {[wrapObject "{\\large " "}Ñ"]} then {
- message "large text set"
- } else {
- message "enter large text"
- }
- }
- proc Large {} {
- if {[wrapObject "{\\Large " "}Ñ"]} then {
- message "Large text set"
- } else {
- message "enter Large text"
- }
- }
- proc LARGE {} {
- if {[wrapObject "{\\LARGE " "}Ñ"]} then {
- message "LARGE text set"
- } else {
- message "enter LARGE text"
- }
- }
- proc huge {} {
- if {[wrapObject "{\\huge " "}Ñ"]} then {
- message "huge text set"
- } else {
- message "enter huge text"
- }
- }
- proc Huge {} {
- if {[wrapObject "{\\Huge " "}Ñ"]} then {
- message "Huge text set"
- } else {
- message "enter Huge text"
- }
- }
-
- #--------------------------------------------------------------------------
- # International:
- #--------------------------------------------------------------------------
-
- proc {ÿ} {} {
- if {[wrapObject "\\`{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter single character"
- }
- }
- proc {ù} {} {
- if {[wrapObject "\\'{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter single character"
- }
- }
- proc {Ö} {} {
- if {[wrapObject "\\^{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter single character"
- }
- }
- proc {Ü} {} {
- if {[wrapObject "\\\"{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter single character"
- }
- }
- proc {¢} {} {
- if {[wrapObject "\\~{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter single character"
- }
- }
- proc {ì} {} {insertObject "\\c\{c\}"}
- proc {é} {} {insertObject "\\c\{C\}"}
- proc {╧} {} {insertObject "\\oe"}
- proc {╬} {} {insertObject "\\OE"}
- proc {╛} {} {insertObject "\\ae"}
- proc {«} {} {insertObject "\\AE"}
- proc {î} {} {insertObject "\\aa"}
- proc {ü} {} {insertObject "\\AA"}
- proc {┐} {} {insertObject "\\o"}
- proc {»} {} {insertObject "\\O"}
- proc {º} {} {insertObject "\\ss"}
- proc {└} {} {insertObject "?`"}
- proc {┴} {} {insertObject "!`"}
-
- #--------------------------------------------------------------------------
- # Environments:
- #--------------------------------------------------------------------------
-
- proc enumerate {} {
- global promptNoisily useStatusBar
- set envName "enumerate"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many items?" 3} numberItems
- if {$numberItems == "cancel"} then {
- return
- } elseif {![isUnsignedInteger $numberItems]} then {
- beep
- message "invalid input"
- return
- }
- if {$numberItems} then {
- set body "\t\\item Ñ"
- for {set i 1} {$i < $numberItems} {incr i} {
- append body "\r\r\t\\item Ñ"
- }
- append body "\r"
- } else {
- set body "\tÑ\r"
- }
- if {[insertEnvironment $envName "" $body]} then {
- nextTabStop
- message "type first item"
- }
- }
- proc itemize {} {
- global promptNoisily useStatusBar
- set envName "itemize"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many items?" 3} numberItems
- if {$numberItems == "cancel"} then {
- return
- } elseif {![isUnsignedInteger $numberItems]} then {
- beep
- message "invalid input"
- return
- }
- if {$numberItems} then {
- set body "\t\\item Ñ"
- for {set i 1} {$i < $numberItems} {incr i} {
- append body "\r\r\t\\item Ñ"
- }
- append body "\r"
- } else {
- set body "\tÑ\r"
- }
- if {[insertEnvironment $envName "" $body]} then {
- nextTabStop
- message "type first item"
- }
- }
- proc description {} {
- global promptNoisily useStatusBar
- set envName "description"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many items?" 3} numberItems
- if {$numberItems == "cancel"} then {
- return
- } elseif {![isUnsignedInteger $numberItems]} then {
- beep
- message "invalid input"
- return
- }
- if {$numberItems} then {
- set body "\t\\item\[Ñ\] Ñ"
- for {set i 1} {$i < $numberItems} {incr i} {
- append body "\r\r\t\\item\[Ñ\] Ñ"
- }
- append body "\r"
- } else {
- set body "\tÑ\r"
- }
- if {[insertEnvironment $envName "" $body]} then {
- nextTabStop
- message "type first item label"
- }
- }
- proc thebibliography {} {
- global promptNoisily useStatusBar
- set envName "thebibliography"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many items?" 3} numberItems
- if {$numberItems == "cancel"} then {
- return
- } elseif {![isUnsignedInteger $numberItems]} then {
- beep
- message "invalid input"
- return
- }
- set arg "{9}"
- if {$numberItems} then {
- if {$numberItems > 9} then {set arg "{99}"}
- set body "\t\\bibitem{Ñ} Ñ"
- for {set i 1} {$i < $numberItems} {incr i} {
- append body "\r\r\t\\bibitem{Ñ} Ñ"
- }
- append body "\r"
- } else {
- set body "\tÑ\r"
- }
- if {[insertEnvironment $envName $arg $body]} then {
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {(9)+} [getPos]]
- eval select $searchResult
- message "Change the length of the key field?"
- }
- }
- proc slide {} { doWrapEnvironment "slide" }
- proc overlay {} { doWrapEnvironment "overlay" }
- proc note {} { doWrapEnvironment "note" }
- proc figure {} {
- global useBoxMacro boxMacroName
- set envName "figure"
- set envArg "tbp"
- set arg "\[$envArg\]"
- set body ""
- if {$useBoxMacro} then {
- append body "\t\\centerline{\\$boxMacroName{Ñ}}\r"
- }
- append body "\t\\caption{Ñ}\r"
- append body "\t\\protect\\label{Ñ}\r"
- if {$useBoxMacro} then {
- if {![insertEnvironment $envName $arg $body]} then {return}
- } else {
- wrapEnvironment $envName $arg $body
- }
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 "$envArg" [getPos]]
- eval select $searchResult
- message "Modify this argument? (t=top; b=bottom; p=page; h=here; !=try harder)"
- }
- proc table {} {
- set envName "table"
- set envArg "tbp"
- # The following statement puts the caption at the top:
- set arg "\[$envArg\]\r[getIndentation [getPos]]\t\\caption{Ñ}"
- # The following two statements put the caption at the bottom:
- # set arg "\[$envArg\]"
- # set body "\t\\caption{Ñ}\r"
- append body "\t\\protect\\label{Ñ}\r"
- wrapEnvironment $envName $arg $body
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 "$envArg" [getPos]]
- eval select $searchResult
- message "Modify this argument? (t=top; b=bottom; p=page; h=here; !=try harder)"
- }
- proc buildRow {jmax} {
- set txt "Ñ"
- for {set j 1} {$j < $jmax} {incr j} {
- append txt " & Ñ"
- }
- return $txt
- }
- proc tabular {} {
- global promptNoisily useStatusBar
- set envName "tabular"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many rows?" 3} numberRows
- if {$numberRows == "cancel"} then {
- return
- } elseif {$numberRows == 0} then {
- beep
- message "positive number of rows required"
- return
- } elseif {![isUnsignedInteger $numberRows]} then {
- beep
- message "invalid input"
- return
- }
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many columns?" 3} numberCols
- if {$numberCols == "cancel"} then {
- return
- } elseif {$numberCols == 0} then {
- beep
- message "positive number of columns required"
- return
- } elseif {![isUnsignedInteger $numberCols]} then {
- beep
- message "invalid input"
- return
- }
- set arg "{|"
- for {set j 1} {$j <= $numberCols} {incr j} {
- append arg "c|"
- }
- append arg "}"
- set body "\t\\hline\r"
- for {set i 1} {$i <= $numberRows} {incr i} {
- append body "\t[buildRow $numberCols]"
- append body " \\\\\r\t\\hline\r"
- }
- if {[insertEnvironment $envName $arg $body]} then {
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {(c|\|)+} [getPos]]
- select [lindex $searchResult 0] [lindex $searchResult 1]
- message "Modify this argument?"
- }
- }
- proc verbatim {} { doWrapEnvironment "verbatim" }
- proc quote {} { doWrapEnvironment "quote" }
- proc quotation {} { doWrapEnvironment "quotation" }
- proc verse {} { doWrapEnvironment "verse" }
- proc flushleft {} { doWrapEnvironment "flushleft" }
- proc center {} { doWrapEnvironment "center" }
- proc flushright {} { doWrapEnvironment "flushright" }
- proc general {} {
- catch {prompt "What environment?" ""} environmentName
- if {$environmentName != "cancel"} {
- doWrapEnvironment "$environmentName"
- }
- }
-
- #--------------------------------------------------------------------------
- # Boxes:
- #--------------------------------------------------------------------------
-
- proc mbox {} {
- if {[wrapObject "\\mbox{" "}Ñ"]} then {
- message "mbox set"
- } else {
- message "enter text"
- }
- }
- proc makebox {} {
- if {[wrapObject "\\makebox\[Ñ\]\[Ñ\]{" "}Ñ"]} then {
- message "makebox set; enter the width and position"
- } else {
- message "enter the width and position of the makebox, then the text"
- }
- }
- proc fbox {} {
- if {[wrapObject "\\fbox{" "}Ñ"]} then {
- message "fbox set"
- } else {
- message "enter text"
- }
- }
- proc framebox {} {
- if {[wrapObject "\\framebox\[Ñ\]\[Ñ\]{" "}Ñ"]} then {
- message "framebox set; enter the width and position"
- } else {
- message "enter the width and position of the framebox, then the text"
- }
- }
- proc newsavebox {} {
- if {[wrapObject "\\newsavebox{" "}Ñ"]} then {
- message "newsavebox defined"
- } else {
- message "enter the command name of the sbox or savebox"
- }
- }
- proc sbox {} {
- if {[wrapObject "\\sbox{Ñ}{" "}Ñ"]} then {
- message "sbox set; enter the command name"
- } else {
- message "enter the command name of the sbox, then the text"
- }
- }
- proc savebox {} {
- if {[wrapObject "\\savebox{Ñ}\[Ñ\]\[Ñ\]{" "}Ñ"]} then {
- message "savebox set; enter the command name"
- } else {
- message "enter the command name of the savebox"
- }
- }
- proc usebox {} {
- if {[wrapObject "\\usebox{" "}Ñ"]} then {
- message "usebox declared"
- } else {
- message "enter the command name of the sbox or savebox"
- }
- }
- proc raisebox {} {
- if {[wrapObject "\\raisebox{Ñ}\[Ñ\]\[Ñ\]{" "}Ñ"]} then {
- message "raisebox set; enter the displacement"
- } else {
- message "enter the displacement of the raisebox"
- }
- }
- proc parbox {} {
- if {[wrapObject "\\parbox\[Ñ\]\{Ñ\}{" "}Ñ"]} then {
- message "parbox set; enter the position and width"
- } else {
- message "enter the position \[b|c|t\] and width of the parbox, then the text"
- }
- }
- proc minipage {} {
- set arg "\[Ñ\]{Ñ}"
- wrapEnvironment "minipage" $arg ""
- nextTabStop
- message "enter the position \[b|c|t\] of the minipage, then the width"
- }
- proc rule {} {
- insertObject "\\rule\[Ñ\]\{Ñ\}{Ñ}Ñ"
- nthTabStop -4
- message "enter the displacement of the rule, then width and height"
- }
-
- #--------------------------------------------------------------------------
- # Misc:
- #--------------------------------------------------------------------------
-
- proc ldots {} {insertObject "\\ldots"}
- proc {en-dash} {} {insertObject "--"}
- proc {em-dash} {} {insertObject "---"}
- proc texLogo {} {insertObject "\\TeX"}
- proc latexLogo {} {insertObject "\\LaTeX"}
- proc latex2eLogo {} {insertObject "\\LaTeXe"}
- proc today {} {insertObject "\\today"}
- proc dag {} {insertObject "\\dag"}
- proc ddag {} {insertObject "\\ddag"}
- proc sectionMark {} {insertObject "\\S"}
- proc paragraphMark {} {insertObject "\\P"}
- proc copyright {} {insertObject "\\copyright"}
- proc pounds {} {insertObject "\\pounds"}
- proc quotes {} {
- if {[wrapObject "`" "'Ñ"]} then {
- message "text quoted"
- } else {
- message "enter text"
- }
- }
- proc dblQuotes {} {
- if {[wrapObject "``" "''Ñ"]} then {
- message "text double quoted"
- } else {
- message "enter text"
- }
- }
- proc marginalNote {} {
- if {[wrapObject "\\marginpar{" "}Ñ"]} then {
- message "marginal note set"
- } else {
- message "enter marginal note"
- }
- }
- proc footnote {} {
- if {[wrapObject "\\footnote{" "}Ñ"]} then {
- message "footnote set"
- } else {
- message "enter footnote"
- }
- }
- proc label {} {
- if {[wrapObject "\\label{" "}Ñ"]} then {
- message "label defined"
- } else {
- message "enter label"
- }
- }
- proc ref {} {
- if {[wrapObject "\\ref{" "}Ñ"]} then {
- message "cross-reference made"
- } else {
- message "enter cross-reference"
- }
- }
- proc pageref {} {
- if {[wrapObject "\\pageref{" "}Ñ"]} then {
- message "page reference made"
- } else {
- message "enter page reference"
- }
- }
- proc cite {} {
- if {[wrapObject "\\cite{" "}Ñ"]} then {
- message "citation made"
- } else {
- message "enter citation"
- }
- }
- # Insert an \item or a \bibitem, depending on the context.
- proc insertItem {} {
- # global TeXmodeVars
- # if {$TeXmodeVars(expertMode) == 0} then {
- # if {![isInDocument]} then {
- # if {$TeXmodeVars(searchNoisily)} {beep}
- # case [askyesno "The cursor is not in the document environment.\
- # \rContinue the operation?"] in {
- # "yes" {}
- # "no" {error "insertItem: out of context"}
- # }
- # }
- # }
- set command [eval getText [searchEnvironment]]
- set environment [extractCommandArg $command]
- case $environment in {
- {itemize enumerate} {
- set text "\\item Ñ"
- }
- "description" {
- set text "\\item\[Ñ\] Ñ"
- }
- "thebibliography" {
- set text "\\bibitem{Ñ} Ñ"
- }
- default {
- beep
- message "insertItem: cursor in $environment environment"
- return
- }
- }
- set pos [getPos]
- # Indentation should mirror that of an existing \item
- # (if it exists)
- insertText [openingCarriageReturn]$text
- goto $pos
- nextTabStop
- }
-
-
- #############################################################################
- #
- # Math Mode Macros
- #
- #############################################################################
-
- #--------------------------------------------------------------------------
- # Math Modes:
- #--------------------------------------------------------------------------
-
- proc texMath {} {
- checkMathMode "texMath" 0
- if {[wrapObject "$" "$Ñ"]} then {
- message "formula set"
- } else {
- message "enter formula"
- }
- }
- proc texDisplaymath {} {
- checkMathMode "texDisplaymath" 0
- if {[wrapObject "$$" "$$Ñ"]} then {
- message "displayed formula set"
- } else {
- message "enter displayed formula"
- }
- }
- proc latexMath {} {
- checkMathMode "latexMath" 0
- if {[wrapObject "\\( " " \\)Ñ"]} then {
- message "formula set"
- } else {
- message "enter formula"
- }
- }
- proc latexDisplaymath {} {
- checkMathMode "latexDisplaymath" 0
- if {[wrapObject "\\\[ " " \\\]Ñ"]} then {
- message "displayed formula set"
- } else {
- message "enter displayed formula"
- }
- }
-
- #--------------------------------------------------------------------------
- # Math Style:
- #--------------------------------------------------------------------------
-
- proc mathit {} {
- checkMathMode "mathit" 1
- if {[wrapObject "\\mathit{" "}Ñ"]} then {
- message "selected text is math italic"
- } else {
- message "enter text to be math italic"
- }
- }
- proc mathrm {} {
- checkMathMode "mathrm" 1
- if {[wrapObject "\\mathrm{" "}Ñ"]} then {
- message "selected text is math roman"
- } else {
- message "enter text to be math roman"
- }
- }
- proc mathbf {} {
- checkMathMode "mathbf" 1
- if {[wrapObject "\\mathbf{" "}Ñ"]} then {
- message "selected text is math bold"
- } else {
- message "enter text to be math bold"
- }
- }
- proc mathsf {} {
- checkMathMode "mathsf" 1
- if {[wrapObject "\\mathsf{" "}Ñ"]} then {
- message "selected text is math sans serif"
- } else {
- message "enter text to be math sans serif"
- }
- }
- proc mathtt {} {
- checkMathMode "mathtt" 1
- if {[wrapObject "\\mathtt{" "}Ñ"]} then {
- message "selected text is math typewriter"
- } else {
- message "enter text to be math typewriter"
- }
- }
- proc mathcal {} {
- checkMathMode "mathcal" 1
- # Allow upper-case arguments only:
- if {[isSelection] && ![isUppercase]} then {
- alertnote "argument to \\mathcal must be uppercase"
- return
- }
- if {[wrapObject "\\mathcal{" "}Ñ"]} then {
- message "selected text is calligraphic"
- } else {
- message "enter text to be calligraphic (UPPERCASE letters only)"
- }
- }
- proc displaystyle {} {
- checkMathMode "displaystyle" 1
- if {[wrapObject "{\\displaystyle " "}Ñ"]} then {
- message "displaystyle set"
- } else {
- message "enter displaystyle text"
- }
- }
- proc textstyle {} {
- checkMathMode "textstyle" 1
- if {[wrapObject "{\\textstyle " "}Ñ"]} then {
- message "textstyle set"
- } else {
- message "enter textstyle text"
- }
- }
- proc scriptstyle {} {
- checkMathMode "scriptstyle" 1
- if {[wrapObject "{\\scriptstyle " "}Ñ"]} then {
- message "scriptstyle set"
- } else {
- message "enter scriptstyle text"
- }
- }
- proc scriptscriptstyle {} {
- checkMathMode "scriptscriptstyle" 1
- if {[wrapObject "{\\scriptscriptstyle " "}Ñ"]} then {
- message "scriptscriptstyle set"
- } else {
- message "enter scriptscriptstyle text"
- }
- }
-
- #--------------------------------------------------------------------------
- # Math Environments:
- #--------------------------------------------------------------------------
-
- proc math {} { checkMathMode "math" 0; doWrapEnvironment "math" }
- proc displaymath {} {
- checkMathMode "displaymath" 0
- doWrapEnvironment "displaymath"
- }
- proc equation {} {
- checkMathMode "equation" 0
- set envName "equation"
- set body "\t\\label{Ñ}\r"
- if {[wrapEnvironment $envName "" $body]} then {
- set msgText "equation wrapped"
- } else {
- set msgText "enter equation"
- }
- nextTabStop
- message $msgText
- }
- proc eqnarrayStar {} {
- global promptNoisily useStatusBar
- checkMathMode "eqnarrayStar" 0
- set envName "eqnarray*"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many rows?" 3} numberRows
- if {$numberRows == "cancel"} then {
- return
- } elseif {$numberRows == 0} then {
- beep
- message "positive number of rows required"
- return
- } elseif {![isUnsignedInteger $numberRows]} then {
- beep
- message "invalid input"
- return
- }
- set row "\t[buildRow 3]"
- for {set i 1} {$i < $numberRows} {incr i} {
- append body $row
- append body " \\\\\r"
- }
- append body $row
- append body "\r"
- if {[insertEnvironment $envName "" $body]} then {
- nextTabStop
- message "type first item"
- }
- }
- proc eqnarray {} {
- global promptNoisily useStatusBar
- checkMathMode "eqnarray" 0
- set envName "eqnarray"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many rows?" 3} numberRows
- if {$numberRows == "cancel"} then {
- return
- } elseif {$numberRows == 0} then {
- beep
- message "positive number of rows required"
- return
- } elseif {![isUnsignedInteger $numberRows]} then {
- beep
- message "invalid input"
- return
- }
- set row "\t[buildRow 3]\r\t\\label{Ñ}"
- for {set i 1} {$i < $numberRows} {incr i} {
- append body $row
- append body " \\\\\r"
- }
- append body $row
- append body "\r"
- if {[insertEnvironment $envName "" $body]} then {
- nextTabStop
- message "type first item"
- }
- }
- proc myArray {} {
- global promptNoisily useStatusBar
- checkMathMode "myArray" 1
- set envName "array"
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many rows?" 3} numberRows
- if {$numberRows == "cancel"} then {
- return
- } elseif {$numberRows == 0} then {
- beep
- message "positive number of rows required"
- return
- } elseif {![isUnsignedInteger $numberRows]} then {
- beep
- message "invalid input"
- return
- }
- if {$promptNoisily && $useStatusBar} {beep}
- catch {sPrompt "$envName: how many columns?" 3} numberCols
- if {$numberCols == "cancel"} then {
- return
- } elseif {$numberCols == 0} then {
- beep
- message "positive number of columns required"
- return
- } elseif {![isUnsignedInteger $numberCols]} then {
- beep
- message "invalid input"
- return
- }
- set arg "{"
- for {set j 1} {$j <= $numberCols} {incr j} {
- append arg "c"
- }
- append arg "}"
- set row "\t[buildRow $numberCols]"
- for {set i 1} {$i < $numberRows} {incr i} {
- append body $row
- append body " \\\\\r"
- }
- append body $row
- append body "\r"
- if {[insertEnvironment $envName $arg $body]} then {
- set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {c+} [getPos]]
- select [lindex $searchResult 0] [lindex $searchResult 1]
- message "Modify this argument?"
- }
- }
-
- #--------------------------------------------------------------------------
- # Formulas:
- #--------------------------------------------------------------------------
-
- proc subscript {} {
- checkMathMode "subscript" 1
- if {[wrapObject "_{" "}Ñ"]} then {
- message "subscript set"
- } else {
- message "enter subscript"
- }
- }
- proc superscript {} {
- checkMathMode "superscript" 1
- if {[wrapObject "^{" "}Ñ"]} then {
- message "superscript set"
- } else {
- message "enter superscript"
- }
- }
- proc fraction {} {
- checkMathMode "fraction" 1
- set currentPos [getPos]
- if {[isSelection]} then {
- set selection [getSelect]
- set args [split $selection /]
- set len [llength $args]
- deleteText $currentPos [selEnd]
- if {$len == 1} then {
- insertObject "\\frac{$selection}{Ñ}Ñ"
- goto $currentPos
- nextTabStop
- message "enter denominator"
- } else {
- set firstArg [lindex $args 0]
- set restArgs [lrange $args 1 [expr $len-1]]
- insertObject "\\frac{$firstArg}{[join $restArgs /]}"
- if {$len > 2} {message "beware of multiple /"}
- }
- } else {
- insertObject "\\frac{Ñ}{Ñ}Ñ"
- goto $currentPos
- nextTabStop
- message "enter numerator"
- }
- }
- proc squareRoot {} {
- checkMathMode "squareRoot" 1
- if {[wrapObject "\\sqrt{" "}Ñ"]} then {
- message "square root set"
- } else {
- message "enter formula"
- }
- }
- proc nthRoot {} {
- checkMathMode "nthRoot" 1
- if {[wrapObject "\\sqrt\[Ñ\]{" "}Ñ"]} then {
- message "enter root"
- } else {
- message "enter root, then formula"
- }
- }
- proc oneParameter {} {
- checkMathMode "oneParameter" 1
- catch {prompt "Command name?" "sqrt"} commandName
- if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}Ñ"}
- }
- proc twoParameters {} {
- checkMathMode "twoParameters" 1
- catch {prompt "Command name?" "frac"} commandName
- if {$commandName != "cancel"} then {
- set currentPos [getPos]
- if {[insertObject "\\$commandName{Ñ}{Ñ}Ñ"]} then {
- goto $currentPos
- nextTabStop
- }
- }
- }
-
- #--------------------------------------------------------------------------
- # Greek:
- #--------------------------------------------------------------------------
-
- proc alpha {} {checkMathMode "alpha" 1; insertObject "\\alpha"}
- proc beta {} {checkMathMode "beta" 1; insertObject "\\beta"}
- proc gamma {} {checkMathMode "gamma" 1; insertObject "\\gamma"}
- proc delta {} {checkMathMode "delta" 1; insertObject "\\delta"}
- proc epsilon {} {checkMathMode "epsilon" 1; insertObject "\\epsilon"}
- proc zeta {} {checkMathMode "zeta" 1; insertObject "\\zeta"}
- proc eta {} {checkMathMode "eta" 1; insertObject "\\eta"}
- proc theta {} {checkMathMode "theta" 1; insertObject "\\theta"}
- proc iota {} {checkMathMode "iota" 1; insertObject "\\iota"}
- proc kappa {} {checkMathMode "kappa" 1; insertObject "\\kappa"}
- proc lambda {} {checkMathMode "lambda" 1; insertObject "\\lambda"}
- proc mu {} {checkMathMode "mu" 1; insertObject "\\mu"}
- proc nu {} {checkMathMode "nu" 1; insertObject "\\nu"}
- proc xi {} {checkMathMode "xi" 1; insertObject "\\xi"}
- proc omicron {} {checkMathMode "omicron" 1; insertObject "o"}
- proc pi {} {checkMathMode "pi" 1; insertObject "\\pi"}
- proc rho {} {checkMathMode "rho" 1; insertObject "\\rho"}
- proc sigma {} {checkMathMode "sigma" 1; insertObject "\\sigma"}
- proc tau {} {checkMathMode "tau" 1; insertObject "\\tau"}
- proc upsilon {} {checkMathMode "upsilon" 1; insertObject "\\upsilon"}
- proc phi {} {checkMathMode "phi" 1; insertObject "\\phi"}
- proc chi {} {checkMathMode "chi" 1; insertObject "\\chi"}
- proc psi {} {checkMathMode "psi" 1; insertObject "\\psi"}
- proc omega {} {checkMathMode "omega" 1; insertObject "\\omega"}
-
- proc Gamma {} {checkMathMode "Gamma" 1; insertObject "\\Gamma"}
- proc Delta {} {checkMathMode "Delta" 1; insertObject "\\Delta"}
- proc Theta {} {checkMathMode "Theta" 1; insertObject "\\Theta"}
- proc Lambda {} {checkMathMode "Lambda" 1; insertObject "\\Lambda"}
- proc Xi {} {checkMathMode "Xi" 1; insertObject "\\Xi"}
- proc Pi {} {checkMathMode "Pi" 1; insertObject "\\Pi"}
- proc Sigma {} {checkMathMode "Sigma" 1; insertObject "\\Sigma"}
- proc Upsilon {} {checkMathMode "Upsilon" 1; insertObject "\\Upsilon"}
- proc Phi {} {checkMathMode "Phi" 1; insertObject "\\Phi"}
- proc Psi {} {checkMathMode "Psi" 1; insertObject "\\Psi"}
- proc Omega {} {checkMathMode "Omega" 1; insertObject "\\Omega"}
-
- proc varepsilon {} {checkMathMode "varepsilon" 1; insertObject "\\varepsilon"}
- proc vartheta {} {checkMathMode "vartheta" 1; insertObject "\\vartheta"}
- proc varpi {} {checkMathMode "varpi" 1; insertObject "\\varpi"}
- proc varrho {} {checkMathMode "varrho" 1; insertObject "\\varrho"}
- proc varsigma {} {checkMathMode "varsigma" 1; insertObject "\\varsigma"}
- proc varphi {} {checkMathMode "varphi" 1; insertObject "\\varphi"}
-
- #--------------------------------------------------------------------------
- # Binary Ops:
- #--------------------------------------------------------------------------
-
- proc pm {} {checkMathMode "pm" 1; insertObject "\\pm"}
- proc mp {} {checkMathMode "mp" 1; insertObject "\\mp"}
- proc times {} {checkMathMode "times" 1; insertObject "\\times"}
- proc div {} {checkMathMode "div" 1; insertObject "\\div"}
- proc ast {} {checkMathMode "ast" 1; insertObject "\\ast"}
- proc star {} {checkMathMode "star" 1; insertObject "\\star"}
- proc circ {} {checkMathMode "circ" 1; insertObject "\\circ"}
- proc bullet {} {checkMathMode "bullet" 1; insertObject "\\bullet"}
- proc cdot {} {checkMathMode "cdot" 1; insertObject "\\cdot"}
- proc cap {} {checkMathMode "cap" 1; insertObject "\\cap"}
- proc cup {} {checkMathMode "cup" 1; insertObject "\\cup"}
- proc uplus {} {checkMathMode "uplus" 1; insertObject "\\uplus"}
- proc sqcap {} {checkMathMode "sqcap" 1; insertObject "\\sqcap"}
- proc sqcup {} {checkMathMode "sqcup" 1; insertObject "\\sqcup"}
- proc vee {} {checkMathMode "vee" 1; insertObject "\\vee"}
- proc wedge {} {checkMathMode "wedge" 1; insertObject "\\wedge"}
- proc setminus {} {checkMathMode "setminus" 1; insertObject "\\setminus"}
- proc wr {} {checkMathMode "wr" 1; insertObject "\\wr"}
- proc diamond {} {checkMathMode "diamond" 1; insertObject "\\diamond"}
- proc bigtriangleup {} {
- checkMathMode "bigtriangleup" 1; insertObject "\\bigtriangleup"
- }
- proc bigtriangledown {} {
- checkMathMode "bigtriangledown" 1; insertObject "\\bigtriangledown"
- }
- proc triangleleft {} {
- checkMathMode "triangleleft" 1; insertObject "\\triangleleft"
- }
- proc triangleright {} {
- checkMathMode "triangleright" 1; insertObject "\\triangleright"
- }
- proc lhd {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "lhd" 1; insertObject "\\lhd"
- }
- }
- proc rhd {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "rhd" 1; insertObject "\\rhd"
- }
- }
- proc unlhd {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "unlhd" 1; insertObject "\\unlhd"
- }
- }
- proc unrhd {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "unrhd" 1; insertObject "\\unrhd"
- }
- }
- proc oplus {} {checkMathMode "oplus" 1; insertObject "\\oplus"}
- proc ominus {} {checkMathMode "ominus" 1; insertObject "\\ominus"}
- proc otimes {} {checkMathMode "otimes" 1; insertObject "\\otimes"}
- proc oslash {} {checkMathMode "oslash" 1; insertObject "\\oslash"}
- proc odot {} {checkMathMode "odot" 1; insertObject "\\odot"}
- proc bigcirc {} {checkMathMode "bigcirc" 1; insertObject "\\bigcirc"}
- proc dagger {} {checkMathMode "dagger" 1; insertObject "\\dagger"}
- proc ddagger {} {checkMathMode "ddagger" 1; insertObject "\\ddagger"}
- proc amalg {} {checkMathMode "amalg" 1; insertObject "\\amalg"}
-
- #--------------------------------------------------------------------------
- # Relations:
- #--------------------------------------------------------------------------
-
- proc leq {} {checkMathMode "leq" 1; insertObject "\\leq"}
- proc prec {} {checkMathMode "prec" 1; insertObject "\\prec"}
- proc preceq {} {checkMathMode "preceq" 1; insertObject "\\preceq"}
- proc myLl {} {checkMathMode "myLl" 1; insertObject "\\ll"}
- proc subset {} {checkMathMode "subset" 1; insertObject "\\subset"}
- proc subseteq {} {checkMathMode "subseteq" 1; insertObject "\\subseteq"}
- proc sqsubset {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "sqsubset" 1; insertObject "\\sqsubset"
- }
- }
- proc sqsubseteq {} {checkMathMode "sqsubseteq" 1; insertObject "\\sqsubseteq"}
- proc in {} {checkMathMode "in" 1; insertObject "\\in"}
- proc vdash {} {checkMathMode "vdash" 1; insertObject "\\vdash"}
-
- proc geq {} {checkMathMode "geq" 1; insertObject "\\geq"}
- proc succ {} {checkMathMode "succ" 1; insertObject "\\succ"}
- proc succeq {} {checkMathMode "succeq" 1; insertObject "\\succeq"}
- proc gg {} {checkMathMode "gg" 1; insertObject "\\gg"}
- proc supset {} {checkMathMode "supset" 1; insertObject "\\supset"}
- proc supseteq {} {checkMathMode "supseteq" 1; insertObject "\\supseteq"}
- proc sqsupset {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "sqsupset" 1; insertObject "\\sqsupset"
- }
- }
- proc sqsupseteq {} {checkMathMode "sqsupseteq" 1; insertObject "\\sqsupseteq"}
- proc ni {} {checkMathMode "ni" 1; insertObject "\\ni"}
- proc dashv {} {checkMathMode "dashv" 1; insertObject "\\dashv"}
-
- proc equiv {} {checkMathMode "equiv" 1; insertObject "\\equiv"}
- proc sim {} {checkMathMode "sim" 1; insertObject "\\sim"}
- proc simeq {} {checkMathMode "simeq" 1; insertObject "\\simeq"}
- proc asymp {} {checkMathMode "asymp" 1; insertObject "\\asymp"}
- proc approx {} {checkMathMode "approx" 1; insertObject "\\approx"}
- proc cong {} {checkMathMode "cong" 1; insertObject "\\cong"}
- proc neq {} {checkMathMode "neq" 1; insertObject "\\neq"}
- proc doteq {} {checkMathMode "doteq" 1; insertObject "\\doteq"}
- proc propto {} {checkMathMode "propto" 1; insertObject "\\propto"}
-
- proc models {} {checkMathMode "models" 1; insertObject "\\models"}
- proc perp {} {checkMathMode "perp" 1; insertObject "\\perp"}
- proc mid {} {checkMathMode "mid" 1; insertObject "\\mid"}
- proc parallel {} {checkMathMode "parallel" 1; insertObject "\\parallel"}
- proc bowtie {} {checkMathMode "bowtie" 1; insertObject "\\bowtie"}
- proc myJoin {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "myJoin" 1; insertObject "\\join"
- }
- }
- proc smile {} {checkMathMode "smile" 1; insertObject "\\smile"}
- proc frown {} {checkMathMode "frown" 1; insertObject "\\frown"}
-
- #--------------------------------------------------------------------------
- # Arrows:
- #--------------------------------------------------------------------------
-
- proc leftarrow {} {checkMathMode "leftarrow" 1; insertObject "\\leftarrow"}
- proc Leftarrow {} {checkMathMode "Leftarrow" 1; insertObject "\\Leftarrow"}
- proc rightarrow {} {checkMathMode "rightarrow" 1; insertObject "\\rightarrow"}
- proc Rightarrow {} {checkMathMode "Rightarrow" 1; insertObject "\\Rightarrow"}
- proc leftrightarrow {} {
- checkMathMode "leftrightarrow" 1; insertObject "\\leftrightarrow"
- }
- proc Leftrightarrow {} {
- checkMathMode "Leftrightarrow" 1; insertObject "\\Leftrightarrow"
- }
- proc mapsto {} {checkMathMode "mapsto" 1; insertObject "\\mapsto"}
- proc hookleftarrow {} {
- checkMathMode "hookleftarrow" 1; insertObject "\\hookleftarrow"
- }
- proc leftharpoonup {} {
- checkMathMode "leftharpoonup" 1; insertObject "\\leftharpoonup"
- }
- proc leftharpoondown {} {
- checkMathMode "leftharpoondown" 1; insertObject "\\leftharpoondown"
- }
- proc rightleftharpoons {} {
- checkMathMode "rightleftharpoons" 1; insertObject "\\rightleftharpoons"
- }
-
- proc longleftarrow {} {
- checkMathMode "longleftarrow" 1; insertObject "\\longleftarrow"
- }
- proc Longleftarrow {} {
- checkMathMode "Longleftarrow" 1; insertObject "\\Longleftarrow"
- }
- proc longrightarrow {} {
- checkMathMode "longrightarrow" 1; insertObject "\\longrightarrow"
- }
- proc Longrightarrow {} {
- checkMathMode "Longrightarrow" 1; insertObject "\\Longrightarrow"
- }
- proc longleftrightarrow {} {
- checkMathMode "longleftrightarrow" 1; insertObject "\\longleftrightarrow"
- }
- proc Longleftrightarrow {} {
- checkMathMode "Longleftrightarrow" 1; insertObject "\\Longleftrightarrow"
- }
- proc longmapsto {} {checkMathMode "longmapsto" 1; insertObject "\\longmapsto"}
- proc hookrightarrow {} {
- checkMathMode "hookrightarrow" 1; insertObject "\\hookrightarrow"
- }
- proc rightharpoonup {} {
- checkMathMode "rightharpoonup" 1; insertObject "\\rightharpoonup"
- }
- proc rightharpoondown {} {
- checkMathMode "rightharpoondown" 1; insertObject "\\rightharpoondown"
- }
- proc leadsto {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "leadsto" 1; insertObject "\\leadsto"
- }
- }
- proc uparrow {} {checkMathMode "uparrow" 1; insertObject "\\uparrow"}
- proc Uparrow {} {checkMathMode "Uparrow" 1; insertObject "\\Uparrow"}
- proc downarrow {} {checkMathMode "downarrow" 1; insertObject "\\downarrow"}
- proc Downarrow {} {checkMathMode "Downarrow" 1; insertObject "\\Downarrow"}
- proc updownarrow {} {checkMathMode "updownarrow" 1; insertObject "\\updownarrow"}
- proc Updownarrow {} {checkMathMode "Updownarrow" 1; insertObject "\\Updownarrow"}
- proc nearrow {} {checkMathMode "nearrow" 1; insertObject "\\nearrow"}
- proc searrow {} {checkMathMode "searrow" 1; insertObject "\\searrow"}
- proc swarrow {} {checkMathMode "swarrow" 1; insertObject "\\swarrow"}
- proc nwarrow {} {checkMathMode "nwarrow" 1; insertObject "\\nwarrow"}
-
- #--------------------------------------------------------------------------
- # Dots:
- #--------------------------------------------------------------------------
-
- proc cdots {} {checkMathMode "cdots" 1; insertObject "\\cdots"}
- proc vdots {} {checkMathMode "vdots" 1; insertObject "\\vdots"}
- proc ddots {} {checkMathMode "ddots" 1; insertObject "\\ddots"}
-
- #--------------------------------------------------------------------------
- # Symbols:
- #--------------------------------------------------------------------------
-
- proc aleph {} {checkMathMode "aleph" 1; insertObject "\\aleph"}
- proc hbar {} {checkMathMode "hbar" 1; insertObject "\\hbar"}
- proc imath {} {checkMathMode "imath" 1; insertObject "\\imath"}
- proc jmath {} {checkMathMode "jmath" 1; insertObject "\\jmath"}
- proc ell {} {checkMathMode "ell" 1; insertObject "\\ell"}
- proc wp {} {checkMathMode "wp" 1; insertObject "\\wp"}
- proc Re {} {checkMathMode "Re" 1; insertObject "\\Re"}
- proc Im {} {checkMathMode "Im" 1; insertObject "\\Im"}
- proc mho {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "mho" 1; insertObject "\\mho"
- }
- }
- proc prime {} {checkMathMode "prime" 1; insertObject "\\prime"}
- proc emptyset {} {checkMathMode "emptyset" 1; insertObject "\\emptyset"}
- proc nabla {} {checkMathMode "nabla" 1; insertObject "\\nabla"}
- proc surd {} {checkMathMode "surd" 1; insertObject "\\surd"}
- proc top {} {checkMathMode "top" 1; insertObject "\\top"}
- proc bot {} {checkMathMode "bot" 1; insertObject "\\bot"}
- # proc | {} {checkMathMode "|" 1; insertObject "\\|"}
- proc angle {} {checkMathMode "angle" 1; insertObject "\\angle"}
- proc forall {} {checkMathMode "forall" 1; insertObject "\\forall"}
- proc exists {} {checkMathMode "exists" 1; insertObject "\\exists"}
- proc neg {} {checkMathMode "neg" 1; insertObject "\\neg"}
- proc flat {} {checkMathMode "flat" 1; insertObject "\\flat"}
- proc natural {} {checkMathMode "natural" 1; insertObject "\\natural"}
- proc sharp {} {checkMathMode "sharp" 1; insertObject "\\sharp"}
- proc backslash {} {checkMathMode "backslash" 1; insertObject "\\backslash"}
- proc partial {} {checkMathMode "partial" 1; insertObject "\\partial"}
- proc infty {} {checkMathMode "infty" 1; insertObject "\\infty"}
- proc Box {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "Box" 1; insertObject "\\Box"
- }
- }
- proc Diamond {} {
- if {[isSymbolPackageLoaded]} then {
- checkMathMode "Diamond" 1; insertObject "\\Diamond"
- }
- }
- proc triangle {} {checkMathMode "triangle" 1; insertObject "\\triangle"}
- proc clubsuit {} {checkMathMode "clubsuit" 1; insertObject "\\clubsuit"}
- proc diamondsuit {} {checkMathMode "diamondsuit" 1; insertObject "\\diamondsuit"}
- proc heartsuit {} {checkMathMode "heartsuit" 1; insertObject "\\heartsuit"}
- proc spadesuit {} {checkMathMode "spadesuit" 1; insertObject "\\spadesuit"}
-
- #--------------------------------------------------------------------------
- # Functions:
- #--------------------------------------------------------------------------
-
- proc arccos {} {checkMathMode "arccos" 1; insertObject "\\arccos"}
- proc arcsin {} {checkMathMode "arcsin" 1; insertObject "\\arcsin"}
- proc arctan {} {checkMathMode "arctan" 1; insertObject "\\arctan"}
- proc arg {} {checkMathMode "arg" 1; insertObject "\\arg"}
- proc cos {} {checkMathMode "cos" 1; insertObject "\\cos"}
- proc cosh {} {checkMathMode "cosh" 1; insertObject "\\cosh"}
- proc cot {} {checkMathMode "cot" 1; insertObject "\\cot"}
- proc coth {} {checkMathMode "coth" 1; insertObject "\\coth"}
- proc csc {} {checkMathMode "csc" 1; insertObject "\\csc"}
- proc deg {} {checkMathMode "deg" 1; insertObject "\\deg"}
- proc det {} {checkMathMode "det" 1; insertObject "\\det"}
- proc dim {} {checkMathMode "dim" 1; insertObject "\\dim"}
- proc exp {} {checkMathMode "exp" 1; insertObject "\\exp"}
- proc gcd {} {checkMathMode "gcd" 1; insertObject "\\gcd"}
- proc hom {} {checkMathMode "hom" 1; insertObject "\\hom"}
- proc inf {} {checkMathMode "inf" 1; insertObject "\\inf"}
- proc ker {} {checkMathMode "ker" 1; insertObject "\\ker"}
- proc lg {} {checkMathMode "lg" 1; insertObject "\\lg"}
- proc lim {} {checkMathMode "lim" 1; insertObject "\\lim"}
- proc liminf {} {checkMathMode "liminf" 1; insertObject "\\liminf"}
- proc limsup {} {checkMathMode "limsup" 1; insertObject "\\limsup"}
- proc ln {} {checkMathMode "ln" 1; insertObject "\\ln"}
- proc log {} {checkMathMode "log" 1; insertObject "\\log"}
- proc max {} {checkMathMode "max" 1; insertObject "\\max"}
- proc min {} {checkMathMode "min" 1; insertObject "\\min"}
- proc Pr {} {checkMathMode "Pr" 1; insertObject "\\Pr"}
- proc sec {} {checkMathMode "sec" 1; insertObject "\\sec"}
- proc sin {} {checkMathMode "sin" 1; insertObject "\\sin"}
- proc sinh {} {checkMathMode "sinh" 1; insertObject "\\sinh"}
- proc sup {} {checkMathMode "sup" 1; insertObject "\\sup"}
- proc tan {} {checkMathMode "tan" 1; insertObject "\\tan"}
- proc tanh {} {checkMathMode "tanh" 1; insertObject "\\tanh"}
-
- proc bmod {} {checkMathMode "bmod" 1; insertObject "\\bmod"}
- proc pmod {} {
- checkMathMode "pmod" 1
- if {[wrapObject "\\pmod{" "}Ñ"]} then {
- message "parenthesized mod set"
- } else {
- message "enter formula"
- }
- }
-
- #--------------------------------------------------------------------------
- # Large Ops:
- #--------------------------------------------------------------------------
-
- proc insertLargeOp {commandName} {
- checkMathMode "$commandName" 1
- set currentPos [getPos]
- insertObject "\\$commandName\_{Ñ}^{Ñ}Ñ"
- goto $currentPos
- nextTabStop
- }
- proc sum {} {insertLargeOp "sum"}
- proc prod {} {insertLargeOp "prod"}
- proc coprod {} {insertLargeOp "coprod"}
- proc int {} {insertLargeOp "int"}
- proc oint {} {insertLargeOp "oint"}
- proc bigcap {} {insertLargeOp "bigcap"}
- proc bigcup {} {insertLargeOp "bigcup"}
- proc bigsqcup {} {insertLargeOp "bigsqcup"}
- proc bigvee {} {insertLargeOp "bigvee"}
- proc bigwedge {} {insertLargeOp "bigwedge"}
- proc bigodot {} {insertLargeOp "bigodot"}
- proc bigotimes {} {insertLargeOp "bigotimes"}
- proc bigoplus {} {insertLargeOp "bigoplus"}
- proc biguplus {} {insertLargeOp "biguplus"}
-
- #--------------------------------------------------------------------------
- # Delimiters:
- #--------------------------------------------------------------------------
-
- proc delimitObject {leftDelim rightDelim} {
- if {[wrapObject $leftDelim $rightDelim]} then {
- message "formula delimited"
- } else {
- message "enter formula"
- }
- }
- proc parentheses {} { checkMathMode "parentheses" 1; delimitObject "(" ")Ñ" }
- proc brackets {} { checkMathMode "brackets" 1; delimitObject "\[" "\]Ñ" }
- proc braces {} { checkMathMode "braces" 1; delimitObject "\\\{" "\\\}Ñ" }
- proc absoluteValue {} { checkMathMode "absoluteValue" 1; delimitObject "|" "|Ñ" }
- proc getDelims {} {
- catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" \
- "brackets" "braces" "angle brackets" "vertical bars" \
- "double bars" "ceiling" "floor"} delimType
- if {$delimType != "cancel"} then {
- case $delimType in {
- "parentheses" {
- set leftDelim "("
- set rightDelim ")"
- }
- "brackets" {
- set leftDelim "\["
- set rightDelim "\]"
- }
- "braces" {
- set leftDelim "\\\{"
- set rightDelim "\\\}"
- }
- "{vertical bars}" {
- set leftDelim "|"
- set rightDelim "|"
- }
- "{double bars}" {
- set leftDelim "\\|"
- set rightDelim "\\|"
- }
- "{angle brackets}" {
- set leftDelim "\\langle"
- set rightDelim "\\rangle"
- }
- "ceiling" {
- set leftDelim "\\lceil"
- set rightDelim "\\rceil"
- }
- "floor" {
- set leftDelim "\\lfloor"
- set rightDelim "\\rfloor"
- }
- default {
- alertnote "\"$delimType\" not recognized"
- return ""
- }
- }
- return [list $leftDelim $rightDelim]
- } else {return ""}
- }
- proc otherDelims {} {
- checkMathMode "otherDelims" 1
- set delims [getDelims]
- if {$delims != ""} then {
- set leftDelim [lindex $delims 0]
- set rightDelim [lindex $delims 1]
- delimitObject "$leftDelim" "$rightDelimÑ"
- }
- }
- proc {half-openInterval} {} {
- checkMathMode "half-openInterval" 1; delimitObject "(" "\]Ñ"
- }
- proc {half-closedInterval} {} {
- checkMathMode "half-closedInterval" 1; delimitObject "\[" ")Ñ"
- }
-
- proc insertBigDelims {leftDelim rightDelim isMultiline} {
- checkMathMode "insertBigDelims" 1
- if {$isMultiline} then {
- alertnote "Multi-line delimiters not yet implemented."
- } else {
- if {[wrapObject $leftDelim $rightDelim]} then {
- message "formula delimited"
- } else {
- message "enter formula"
- }
- }
- }
- proc bigParentheses {} {
- checkMathMode "bigParentheses" 1; insertBigDelims "\\left(" "\\right)Ñ" 0
- }
- proc bigBrackets {} {
- checkMathMode "bigBrackets" 1; insertBigDelims "\\left\[" "\\right\]Ñ" 0
- }
- proc bigBraces {} {
- checkMathMode "bigBraces" 1; insertBigDelims "\\left\\\{" "\\right\\\}Ñ" 0
- }
- proc bigAbsoluteValue {} {
- checkMathMode "bigAbsoluteValue" 1; insertBigDelims "\\left|" "\\right|Ñ" 0
- }
- proc otherBigDelims {} {
- checkMathMode "otherBigDelims" 1
- set delims [getDelims]
- if {$delims != ""} then {
- append leftDelim "\\left" [lindex $delims 0]
- append rightDelim "\\right" [lindex $delims 1]
- insertBigDelims "$leftDelim" "$rightDelimÑ" 0
- }
- }
- proc bigLeftBrace {} { checkMathMode "bigLeftBrace" 1; insertBigDelims "\\left\\\{" "\\right.Ñ" 0 }
- proc otherMixedBigDelims {} {
- checkMathMode "otherMixedBigDelims" 1
- catch {prompt "Choose LEFT delimiter:" "parenthesis" "" "parenthesis" \
- "bracket" "brace" "vertical bar" "double bar" \
- "angle bracket" "ceiling" "floor" "slash" "backslash" \
- "none"} delimType
- if {$delimType != "cancel"} then {
- case $delimType in {
- "parenthesis" {set leftDelim "("}
- "bracket" {set leftDelim "\["}
- "brace" {set leftDelim "\\\{"}
- "{vertical bar}" {set leftDelim "|"}
- "{double bar}" {set leftDelim "\\|"}
- "{angle bracket}" {set leftDelim "\\langle"}
- "ceiling" {set leftDelim "\\lceil"}
- "floor" {set leftDelim "\\lfloor"}
- "slash" {set leftDelim "/"}
- "backslash" {set leftDelim "\\backslash"}
- "none" {set leftDelim "."}
- default {
- alertnote "\"$delimType\" not recognized"
- return
- }
- }
- catch {prompt "Choose RIGHT delimiter:" "parenthesis" "" "parenthesis" \
- "bracket" "brace" "vertical bar" "double bar" \
- "angle bracket" "ceiling" "floor" "slash" "backslash" \
- "none"} delimType
- if {$delimType != "cancel"} then {
- case $delimType in {
- "parenthesis" {set rightDelim ")"}
- "bracket" {set rightDelim "\]"}
- "brace" {set rightDelim "\\\}"}
- "{vertical bar}" {set rightDelim "|"}
- "{double bar}" {set rightDelim "\\|"}
- "{angle bracket}" {set rightDelim "\\rangle"}
- "ceiling" {set rightDelim "\\rceil"}
- "floor" {set rightDelim "\\rfloor"}
- "slash" {set rightDelim "/"}
- "backslash" {set rightDelim "\\backslash"}
- "none" {set rightDelim "."}
- default {
- alertnote "\"$delimType\" not recognized"
- return
- }
- }
- insertBigDelims "\\left$leftDelim" "\\right$rightDelimÑ" 0
- }
- }
- }
-
- #--------------------------------------------------------------------------
- # Accents:
- #--------------------------------------------------------------------------
-
- proc acute {} {
- checkMathMode "acute" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\acute{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc bar {} {
- checkMathMode "bar" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\bar{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc breve {} {
- checkMathMode "breve" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\breve{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc check {} {
- checkMathMode "check" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\check{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc dot {} {
- checkMathMode "dot" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\dot{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc ddot {} {
- checkMathMode "ddot" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\ddot{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc grave {} {
- checkMathMode "grave" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\grave{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc hat {} {
- checkMathMode "hat" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\hat{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc tilde {} {
- checkMathMode "tilde" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\tilde{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
- proc vec {} {
- checkMathMode "vec" 1
- if {[isSelection] > 1} then {
- alertnote "Warning: only a single character may be accented!"
- }
- if {[wrapObject "\\vec{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter one character"
- }
- }
-
- proc widehat {} {
- checkMathMode "widehat" 1
- if {[isSelection] > 3} then {
- alertnote "Warning: only a few characters may be accented!"
- }
- if {[wrapObject "\\widehat{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter a few characters"
- }
- }
- proc widetilde {} {
- checkMathMode "widetilde" 1
- if {[isSelection] > 3} then {
- alertnote "Warning: only a few characters may be accented!"
- }
- if {[wrapObject "\\widetilde{" "}Ñ"]} then {
- message "accent set"
- } else {
- message "enter a few characters"
- }
- }
-
- proc imath {} {checkMathMode "imath" 1; insertObject "\\imath"}
- proc jmath {} {checkMathMode "jmath" 1; insertObject "\\jmath"}
-
- #--------------------------------------------------------------------------
- # Grouping:
- #--------------------------------------------------------------------------
-
- proc underline {} {
- checkMathMode "underline" 1
- if {[wrapObject "\\underline{" "}Ñ"]} then {
- message "selection underlined"
- } else {
- message "enter text"
- }
- }
- proc overline {} {
- checkMathMode "overline" 1
- if {[wrapObject "\\overline{" "}Ñ"]} then {
- message "selection overlined"
- } else {
- message "enter text"
- }
- }
- proc underbrace {} {
- checkMathMode "underbrace" 1
- if {[wrapObject "\\underbrace{" "}Ñ"]} then {
- message "selection underbraced"
- } else {
- message "enter text"
- }
- }
- proc overbrace {} {
- checkMathMode "overbrace" 1
- if {[wrapObject "\\overbrace{" "}Ñ"]} then {
- message "selection overbraced"
- } else {
- message "enter text"
- }
- }
- proc stackrel {} {
- checkMathMode "stackrel" 1
- set currentPos [getPos]
- if {[insertObject "\\stackrel{Ñ}{Ñ}Ñ"]} then {
- goto $currentPos
- nextTabStop
- message "1st arg scriptstyle"
- }
- }
-
- #--------------------------------------------------------------------------
- # Spacing:
- #--------------------------------------------------------------------------
-
- proc negThin {} {checkMathMode "negThin" 1; insertObject "\\!"}
- proc thin {} {checkMathMode "thin" 1; insertObject "\\,"}
- proc medium {} {checkMathMode "medium" 1; insertObject "\\:"}
- proc thick {} {checkMathMode "thick" 1; insertObject "\\;"}
- proc quad {} {checkMathMode "quad" 1; insertObject "\\quad"}
- proc qquad {} {checkMathMode "qquad" 1; insertObject "\\qquad"}
- proc hspace {} {
- checkMathMode "hspace" 1
- if {[wrapObject "\\hspace{" "}Ñ"]} then {
- message "spacing set"
- } else {
- message "enter the desired horizontal spacing"
- }
- }
- proc vspace {} {
- checkMathMode "vspace" 1
- if {[wrapObject "\\vspace{" "}Ñ"]} then {
- message "spacing set"
- } else {
- message "enter the desired horizontal spacing"
- }
- }
- proc hfill {} {checkMathMode "hfill" 1; insertObject "\\hfill"}
- proc vfill {} {checkMathMode "vfill" 1; insertObject "\\vfill"}
- proc smallskip {} {checkMathMode "smallskip" 1; insertObject "\\smallskip"}
- proc medskip {} {checkMathMode "medskip" 1; insertObject "\\medskip"}
- proc bigskip {} {checkMathMode "bigskip" 1; insertObject "\\bigskip"}
-
-