; mylatex.emf - personal additions for latex mode ; ; Copyright (C) Christof Boeckler ; ; This program is free software; you can redistribute it and/or modify it ; under the terms of the GNU General Public License as published by the Free ; Software Foundation; either version 2 of the License, or (at your option) ; any later version. ; ; This program is distributed in the hope that it will be useful, but WITHOUT ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ; more details. ; ; You should have received a copy of the GNU General Public License along ; with this program; if not, write to the Free Software Foundation, Inc., ; 675 Mass Ave, Cambridge, MA 02139, USA. ; ; Author: Christof Boeckler ; Version: <071114.2208> ; unrelated to the rest of this file: ; prevent insertion of '\_' when '_' is pressed because that is not useful in mathe mode define-macro my-fhook-latex buffer-unbind-key "_" !emacro ; this will probably be fixed in future ME releases ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; binding keys ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Last .fhook-latex.command-* definition from hklatex.emf: ; set-variable .fhook-latex.command-21 "|bo||tex-insert-underscore|_||" ; for syntax see buffer-init(3) section "Commands and Key Bindings": ; |command-flag|command-nbind|command-name|command-kbind|command-desc| set-variable .fhook-latex.command-22 "|bo||latex-insert-font|C-c C-f|Insert a font|" set-variable .fhook-latex.command-23 "|bo||latex-insert-section|C-c C-s|Insert a sectioning|" set-variable .fhook-latex.command-24 "|bo||latex-insert-environment|C-c C-e|Insert an environment|" set-variable .fhook-latex.command-25 "|bo||latex-insert-item|A-return|Insert a new item|" set-variable .fhook-latex.command-26 "|bo||latex-comment-region|C-c ;|Comment a region|" set-variable .fhook-latex.command-27 "|bo||latex-uncomment-region|C-c :|Uncomment a region|" set-variable .fhook-latex.command-28 "|bo||latex-insert-command|C-c return|Insert a command|" ;set-variable .fhook-latex.command-29 "|bo||latex-insert-math-command|C-c m|Insert a mathematical command|" ;set-variable .fhook-latex.command-30 "|bo||latex-insert-mathfont|C-c C-m|Insert a mathematical font|" ;set-variable .fhook-latex.command-31 "|bo||latex-insert-greek|C-c C-g|Insert a greek character|" ; still missing: rebind comment-start ; buffer-bind-key "comment-start" "C-c C-t" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Description of new bindings and their usage: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Create a new LaTeX environment: C-c C-e ; collision with previous local binding: tex-close-latex-block ; (Create an \end{...} to match the last unclosed \begin{...}) ; default binding was overridden, because the previously bound command will ; be made obsolete by new binding ; Press this combination and you will be asked, which kind of environment you ; want to create. To choose one, you can use tab completion. If an environment ; needs one mandatory argument, the braces are created and your cursor is ; inside of them. If an environment needs more than one mandatory argument or ; can have optional arguments, then you are asked for all mand. args first ; and then for each optional arg. If you press return on the mand. args then ; empty braces are inserted, if you press return with optional arguments, ; then nothing is inserted. ; Insert LaTeX commands: C-c return ; You will be asked for a command name. You can use tab completion. If the ; chosen command needs arguments, you will be asked for them or (if there is ; just one mandatory argument) empty braces are inserted. ; Insert LaTeX math command: C-c m ; Works like the above (C-c return), but it inserts mathematical commands as ; e.g. \frac{}{} or \sum. Argument handling is like with the above functions. ; Comment out a region: mark the region, then press "C-c ;" All lines covered ; by the region (except blank lines) are now commented. ; Uncomment a region: mark the region, then press "C-c :" All lines covered ; by the region (except blank lines) are now uncommented (one comment sign at ; the beginning of every line is removed) ; Both commands work fuzzy, i.e. you don't have to mark the lines precisely, ; but only have to hit a line instead of its exact beginning or end. ; Insert a new \item-line: press A-return ; Meant for itemize-/enumerate-/description-environments. ; Insert a new font command (typewriter, italic,...): C-c C-f ? ; with bdefirst as ? where b is boldface, t is typewriter, and so on. after ; that you have the empty LaTeX-command and the cursor is in it If you ; visibly mark a region before pressing the keys, then the marked region will ; be put inside the command (useful for restyling text). font d means delete ; the surrounding font (works also for all commands that have no arguments) ; Insert special mathematical font commands: C-c C-m ? ; Useful for sets, e.g. the set of real numbers R is commonly written as ; \mathbb{R}. To enter this just type: C-c C-m b r. You can either enter the ; letter that is to be inserted in small or in capital form. b stands for ; blackboard, c stands for caligraphic, f for fraktur, s for script ; Insert greek letters C-c C-g ? ; where ? can be a single small or capital letter. Not every letter is ; accepted and the relation between the command letter and the greek letter ; is somehow strange or arbitrary, but most letters work intuitively. ; E.g. a leads to \alpha, A to \Alpha and so on. ; Insert sectioning commands: C-c C-s ; collision with buffer binding comment-start can be resolved through rebinding ; comment-start to C-c C-t. ; Like in AuXTeX you fist selct which sectioning level you want to insert ; (tab works here as well) and then you can supply an optional reference ; label (press return if you want none). ; Shortcuts for section, subs., subsubs. are 1, 2, 3 (etc., in that order) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; now the code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; define-macro latex-insert-environment ; default behaviour if env. is unknown: do not insert any arguments ; check whether this is first use of command !if ¬ &exist .last-inserted-environment set-variable .last-inserted-environment "itemize" !endif ; list of all (known) completable environments, alphabetically ordered set-variable .all-environments ",abstract,alltt,appendix,array,center,description,displaymath,document,enumerate,eqnarray,equation,figure,filecontents,flushleft,flushright,fussypar,itemize,letter,list,lrbox,math,minipage,note,overlay,picture,quotation,quote,slide,sloppypar,tabbing,table,table*,tabular,thebibliography,theindex,titlepage,trivlist,verbatim,verse," ; list of environments which need exactly one mandatory argument set-variable .onearg-environments ",filecontents,letter,lrbox,thebibliography," ; list of all "special" environments set-variable .special-environments ",array,figure,figure*,list,minipage,table,table*,tabular," ; corresponding description of arguments: ,,,, set-variable .special-description "|,1,1,Column format,vertical position,|,1,0,location on page,|,1,0,Location on page,|,0,2,Standard bullet,List definition,|,3,1,Width,vertical position of box,height of box,inner position of content in box,|,1,0,location on page,|,1,0,location on page,|,1,1,Format of columns,vertical position,|" set-variable #l0 &trboth @ml19 "Environment to be inserted? " .last-inserted-environment .all-environments insert-string "\n\\begin{" insert-string #l0 insert-string "}" ; look for string in the lists, #l1 is an index set-variable #l1 &lfind .onearg-environments #l0 ; env. has one mand. arg. !if &great #l1 "0" ; found in .onearg-environments, i.e. env. needs one argument ; insert construct and go into the mand. argument ; one argument required insert-string "{" ; set mark to return afterwards set-alpha-mark "\xff" insert-string "}" !endif set-variable #l2 &lfind .special-environments #l0 !if &great #l2 "0" ; environment is special ; more than one argument required -> ask for them ; get specification (list entry that is a sublist) in #l9 set-variable #l9 &lget .special-description #l2 ; mandatory argument counter set-variable #l3 &lget #l9 2 ; pointer in list #l9 set-variable #l4 "3" ; set mark to return afterwards set-alpha-mark "\xfe" ; process mandatory arguments !while &great &pdec #l3 1 0 ; there are still mandatory arguments to read ; extract prompt from list #l9 insert-string &cat "{" &cat @ml &cat &lget #l9 &pinc #l4 1 "? " "}" !done ; optional argument counter set-variable #l3 &lget #l9 1 ; go back ([]{}) goto-alpha-mark "\xfe" ; process optional arguments !while &great &pdec #l3 1 0 ; there are still optional arguments to be read ; read argument: prompt is stored in list #l9 ; first read set-variable #l2 &trboth @ml &cat "Optional " &cat &lget #l9 &pinc #l4 1 "? " ; check, whether something was entered !if &great &len #l2 0 ; something was entered insert-string &cat "[" &cat #l2 "]" !endif !done end-of-line !endif insert-string "\n\n\\end{" insert-string #l0 insert-string "}\n" !if &great #l1 "0" ; one argument, we need to jump back into {} goto-alpha-mark "\xff" !else ; otherwise continue on first empty line in the environment 2 backward-line !endif ; store value for next run set-variable .last-inserted-environment #l0 ml-write "[Inserted environment successfully]" !emacro define-macro latex-insert-command !if ¬ &exist .last-inserted-command set-variable .last-inserted-command "footnote" !endif ; default behaviour: insert one mandatory argument ; list of all known (completable) commands set-variable .all-commands ",bigskip,caption,clearpage,medskip,smallskip,footnote,href,label,ref,input,include,includeonly,usepackage,vspace,vspace*,value,usebox,usecounter,twocolumn,today,title,thispagestyle,thanks,textwidth,tableofcontents,symbol,sloppy,fussy,setcounter,setlength,sbox,roman,Roman,ref,refstepcounter,raggedleft,raggedright,quad,qquad,protect,printindex,parbox,pagestyle,pageref,pagenumbering,pagebreak,onecolumn,nopagebreak,noindent,newsavebox,multicolumn,mbox,maketitle,makeindex,makebox,linebreak,tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge,index,hspace,hspace*,hrulefill,hyphenation,hline,hfill,glqq,grqq,flqq,frqq,frame,framebox,fbox,enlargethispage,enlargethispage*,dotfill,date,cline,clearpage,cleardoublepage,cite,centerline,leftline,rightline,bibitem,baselinestretch,renewcommand,renewcommand*,author,arabic,alph,Alph,addtocounter,marginpar," ; list of all commands without argument set-variable .no-argument-commands ",bigskip,clearpage,hfill,medskip,smallskip,vfill,today,textwidth,tableofcontents,sloppy,fussy,raggedleft,raggedright,quad,qquad,protect,printindex,onecolumn,noindent,maketitle,makeindex,tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge,dotfill,clearpage,cleardoublepage,baselinestretch,glqq,grqq,glq,grq," ; list of all commands with more than one mandatory argument set-variable .special-commands ",caption,href,usepackage,twocolumn,setcounter,setlength,sbox,parbox,pagebreak,nopagebreak,multicolumn,makebox,linebreak,framebox,cite,bibitem,renewcommand,renewcommand*,addtocounter,marginpar," ; corresponding description of arguments: ,,,,, set-variable .special-commands-description "|,1,1,Title,short form of title (for TOC etc.),|,0,2,URL,Text to be linked,|,1,1,Package to use,options for the package,|,1,0,Text over both columns,|,0,2,Set which counter,Set it to which value,|,0,2,Which length is to be changed,Set it to what value,|,0,2,Save to which box,Content to save,|,3,2,Width,Content of box (text),Alignment in line,Height,Position of content in box,|,1,0,Urgency of page break (0=low, default 4=high),|,1,0,Urgency of avoiding a page break (0=low, default 4=high),|,0,3,Merge how many column in table,New column alingnment,Content,|,2,1,Content (text),Width,Optional horizontal alignment,|,1,0,Urgency of line break (0=low, default 4=high),|,2,1,Content of box,Width,Horiziontal alignment of content in box,|,1,1,Reference label,Optional addition to the mark,|,1,1,Reference label,Optional mark,|,0,2,Command,Definition,|,0,2,Command,Definition,|,0,2,Counter,Value to add,|,1,1,Right margin notice,Optional left margin notice,|" set-variable #l0 @ml19 "Command to be inserted?" .last-inserted-command .all-commands ; look for string in the lists set-variable #l9 &lfind .no-argument-commands #l0 set-variable #l1 &lfind .special-commands #l0 !if &great #l9 0 ; no arguments insert-string "\\" insert-string #l0 !elif &great #l1 0 ; more complex argument structure ; get specification (list entry that is a sublist) set-variable #l2 &lget .special-commands-description #l1 ; mandatory argument counter set-variable #l1 &lget #l2 2 ; pointer in list #l2 set-variable #l3 "3" insert-string "\\" insert-string #l0 ; set mark to return afterwards set-alpha-mark "\xfe" ; process mandatory arguments !while &great &pdec #l1 1 0 ; there are still mandatory arguments to read ; extract prompt from list #l2 insert-string &cat "{" &cat @ml &cat &lget #l2 &pinc #l3 1 "? " "}" !done ; set mark to return afterwards set-alpha-mark "\xff" goto-alpha-mark "\xfe" ; optional argument counter set-variable #l1 &lget #l2 1 !while &great &pdec #l1 1 0 ; there are optional argument to be read ; prompt is stored in list #l2 set-variable #l4 &trboth @ml &cat "Optional " &cat &lget #l2 &pinc #l3 1 "? " ; check, whether something was entered !if &great &len #l4 0 ; something was entered insert-string &cat "[" &cat #l4 "]" !endif !done goto-alpha-mark "\xff" !else ; create one mandatory argument insert-string "\\" insert-string #l0 insert-string "{}" backward-char !endif ; store value for next run set-variable .last-inserted-command #l0 ml-write "[Inserted command successfully]" !emacro ; TODO: Rewrite this command to work like similar latex-insert-command (i.e. remove &mod hack) define-macro latex-insert-math-command !if ¬ &exist .last-inserted-math-command set-variable .last-inserted-math-command "frac" !endif ; default behaviour: insert no mandatory argument ; list of all completable commands set-variable .all-commands ",acute,aleph,amalg,angle,approx,arccos,arcsin,arctan,asymp,atop,backslash,bar,bigcap,bigcirc,bigcup,bigodot,bigoplus,bigotimes,bigtriangledown,bigtriangleup,bigsqcup,biguplus,bigvee,bigwedge,bmod,bot,bowtie,Box,breve,bullet,cap,cdot,cdots,check,choose,circ,clubsuit,cup,dag,dagger,ddot,ddots,dot,emptyset,equiv,exists,flat,forall,frac,grave,hat,hbar,heartsuit,hookleftarrow,hookrightarrow,infty,Join,langle,Leftarrow,leftarrow,Leftrightarrow,leftrightarrow,Longleftarrow,Longleftrightarrow,longleftrightarrow,Longrightarrow,longrightarrow,mapsto,nearrow,nonumber,notin,overbrace,overline,partial,perp,pmod,prod,rangle,Rightarrow,rightarrow,searrow,setminus,spadesuit,sqrt,stackrel,sum,swarrow,text,tilde,times,top,triangle,triangleleft,triangleright,underbrace,Uparrow,uparrow,Updownarrow,updownarrow,vec,wedge,widehat,widetilde," ; list of all commands with one mandatory argument set-variable .one-argument-commands ",acute,bar,breve,check,ddot,dot,grave,hat,overbrace,overline,pmod,text,tilde,underbrace,underline,vec,widehat,widetilde," ; list of all commands with more than one mandatory argument set-variable .special-commands ",frac,sqrt,stackrel," ; corresponding description of arguments: ,,,, set-variable .special-commands-description "|,2,Numerator,Denominator,|,11,Radicand,Optional: exponent,|,2,Upper symbol, Lower symbol,|" set-variable #l0 @ml19 "Which command should be inserted?" .last-inserted-math-command .all-commands ; look for string in the lists set-variable #l5 &lfind .one-argument-commands #l0 set-variable #l6 &lfind .special-commands #l0 !if &great #l5 "0" ; just create one mandatory argument insert-string "\\" insert-string #l0 insert-string "{}" backward-char !elif &great #l6 "0" ; more complex case ; get specification (list entry that is a sublist) set-variable #l5 &lget .special-commands-description #l6 ; argument counter set-variable #l1 &lget #l5 1 ; index for list #l5 set-variable #l2 "2" ; start with an empty string set-variable #l7 "" !while &less "0" &mod #l1 10 ; as long as there is a remainder, i.e. still mand. arguments ; read argument: prompt is stored in list #l5 set-variable #l8 &cat #l7 &cat "{" &cat @ml &lget #l5 #l2 "}" ; #l8 is a temporary variable set-variable #l7 #l8 ; decrement counter set-variable #l1 &sub #l1 1 ; increment index set-variable #l2 &add #l2 1 !done ; use #l9 for storing optional arguments set-variable #l9 "" !while &less "0" &div #l1 10 ; as long as there is a rest, there are optional argument to be read ; read argument: prompt is stored in list #l5 ; first read set-variable #l3 @ml &lget #l5 #l2 ; check, whether something was entered !if ¬ &iseq "" #l3 ; something was entered set-variable #l8 &cat #l9 &cat "[" &cat #l3 "]" ; #l8 is a temporary variable set-variable #l9 #l8 !endif ; decrement counter set-variable #l1 &sub #l1 10 ; increment index set-variable #l2 &add #l2 1 !done ; now all arguments are ready to be inserted insert-string "\\" insert-string #l0 insert-string &cat #l9 #l7 !else ; no arguments insert-string "\\" insert-string #l0 insert-string " " !endif ; store value for next run set-variable .last-inserted-command #l0 0 ml-write !emacro define-macro latex-comment-region ; expand region to span all affected lines completely set-variable #l0 $window-aline exchange-point-and-mark set-variable #l1 $window-aline !if &great #l1 #l0 ; we're at the bottom end-of-line exchange-point-and-mark beginning-of-line !else ; we're at the top beginning-of-line exchange-point-and-mark end-of-line !endif ; everything is properly marked now kill-region set-position "\xff" set-variable #l2 $buffer-fname !force delete-buffer "*latex-comment-region-tmp*" find-buffer "*latex-comment-region-tmp*" yank beginning-of-buffer replace-string "^" "%" ; remove unnecessary comment lines beginning-of-buffer replace-string "^%\\s*$" "" ; bring content back to where it was taken beginning-of-buffer set-mark end-of-buffer kill-region delete-buffer "*latex-comment-region-tmp*" find-buffer #l2 goto-position "\xff" yank ; remove temporary data from kill ring -1 yank ; remove new empty line; wrong if last marked line has been empty backward-delete-char !emacro define-macro latex-uncomment-region ; expand region to span all affected lines completely set-variable #l0 $window-aline exchange-point-and-mark set-variable #l1 $window-aline !if &great #l1 #l0 ; we're at the bottom end-of-line exchange-point-and-mark beginning-of-line !else ; we're at the top beginning-of-line exchange-point-and-mark end-of-line !endif ; everything is properly marked now kill-region set-position "\xff" set-variable #l2 $buffer-fname !force delete-buffer "*latex-uncomment-region-tmp*" find-buffer "*latex-uncomment-region-tmp*" yank ; remove % characters beginning-of-buffer replace-string "^%" "" ; bring content back to where it was taken beginning-of-buffer set-mark end-of-buffer kill-region delete-buffer "*latex-uncomment-region-tmp*" find-buffer #l2 goto-position "\xff" yank ; remove temporary data from kill ring -1 yank ; remove new empty line; wrong if last marked line has been empty backward-delete-char !emacro define-macro latex-insert-item insert-string "\n\\item " !emacro define-macro latex-insert-font ; inserts/deletes LaTeX2e font commands ; check whether region is visible (active), 0 show-region set-variable #l9 &band $result 0x01 ; #l9 = 1 : region visible ; #l9 = 0 : no region visible !if &equal #l9 1 ; a region is visible ; set end of region to make it complete 3 show-region ; goto end (lower right) of region and save position in an alpha-mark ; first: sort out where the front is ; get line and column numbers set-variable #l0 $window-aline set-variable #l1 $window-acol exchange-point-and-mark set-variable #l2 $window-aline set-variable #l3 $window-acol !if &great #l2 #l0 ; we're at the end, everything is fine !elif &great #l0 #l2 ; we're at the beginning, so go to the other end exchange-point-and-mark !else ; same line, thus check columns !if &great #l1 #l3 ; we're at the beginning, so go to the other end exchange-point-and-mark !endif !endif set-alpha-mark "\xff" ; move point to beginning of region exchange-point-and-mark !endif ; user interaction set-variable #l0 @mc1 "Font to insert [bcefimrstu] or delete font [d]? " "bcdefimrstu" !if &iseq #l0 "d" ; delete font (btw. it works with most surrounding LaTeX commands) ; remove right parenthesis } 1 replace-string "\\([^}]\\)}" "\\1" ; delete left \text..{ 1 search-backward "\\\\[a-z]+{" 1 replace-string "\\\\[a-z]+{" "" ; exit the macro with successfull status !return !endif !if &iseq #l0 "b" ; boldface insert-string "\\textbf{" !elif &iseq #l0 "c" ; small caps insert-string "\\textsc{" !elif &iseq #l0 "e" ; emph insert-string "\\emph{" !elif &iseq #l0 "f" ; sansserif insert-string "\\textsf{" !elif &iseq #l0 "i" ; italic insert-string "\\textit{" !elif &iseq #l0 "m" ; medium insert-string "\\textmd{" !elif &iseq #l0 "r" ; roman insert-string "\\textrm{" !elif &iseq #l0 "s" ; slanted insert-string "\\textsl{" !elif &iseq #l0 "t" ; typewriter insert-string "\\texttt{" !elif &iseq #l0 "u" ; upright insert-string "\\textup{" !endif !if &equal #l9 1 ; region visible => go to the end goto-alpha-mark "\xff" !endif insert-string "}" !if &equal #l9 0 ; no region visible => input expected to be in the construct backward-char !endif ml-write "[Inserted font successfully]" !emacro define-macro latex-insert-mathfont ; insert special mathematical font commands for sets set-variable #l0 @mc1 "Which mathfont should be inserted? [bcfs] " "bcfs" set-variable #l1 &supper @mc1 "Which letter should be inserted in the selected mathfont? [A-Z] " "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" !if &iseq #l0 "b" ; blackboard insert-string "\\mathbb{" !elif &iseq #l0 "c" ; caligraphic insert-string "\\mathcal{" !elif &iseq #l0 "f" ; fraktur insert-string "\\mathfrak{" !elif &iseq #l0 "s" ; script insert-string "\\mathscr{" !endif insert-string #l1 insert-string "}" 0 ml-write !emacro define-macro latex-insert-greek set-variable #l0 @mc1 "Which greek letter should be inserted? " "abdDefFgGiklLmnoOpPrsStTxXyz" !if &iseq #l0 "a" insert-string "\\alpha" !elif &iseq #l0 "b" insert-string "\\beta" !elif &iseq #l0 "d" insert-string "\\delta" !elif &iseq #l0 "D" insert-string "\\Delta" !elif &iseq #l0 "e" insert-string "\\varepsilon" !elif &iseq #l0 "f" insert-string "\\varphi" !elif &iseq #l0 "F" insert-string "\\Phi" !elif &iseq #l0 "g" insert-string "\\gamma" !elif &iseq #l0 "G" insert-string "\\Gamma" !elif &iseq #l0 "i" insert-string "\\iota" !elif &iseq #l0 "k" insert-string "\\kappa" !elif &iseq #l0 "l" insert-string "\\lambda" !elif &iseq #l0 "L" insert-string "\\Lambda" !elif &iseq #l0 "m" insert-string "\\mu" !elif &iseq #l0 "n" insert-string "\\nu" !elif &iseq #l0 "o" insert-string "\\omega" !elif &iseq #l0 "O" insert-string "\\Omega" !elif &iseq #l0 "p" insert-string "\\pi" !elif &iseq #l0 "P" insert-string "\\Pi" !elif &iseq #l0 "r" insert-string "\\varrho" !elif &iseq #l0 "s" insert-string "\\sigma" !elif &iseq #l0 "S" insert-string "\\Sigma" !elif &iseq #l0 "t" insert-string "\\vartheta" !elif &iseq #l0 "T" insert-string "\\Theta" !elif &iseq #l0 "x" insert-string "\\xi" !elif &iseq #l0 "X" insert-string "\\Xi" !elif &iseq #l0 "y" insert-string "\\upsilon" !elif &iseq #l0 "z" insert-string "\\zeta" !endif 0 ml-write !emacro define-macro latex-insert-section ; inserts a LaTeX sectioning command !if ¬ &exist .default-section set-variable .default-section "section" !endif set-variable .all-sections ",part,chapter,section,section*,subsection,subsection*,subsubsection,subsubsection*,paragraph,subparagraph," set-variable #l0 @ml19 "Sectioning to be inserted? " .default-section .all-sections ; allow some abbreviations !if &sequal #l0 "0" set-variable #l0 "chapter" !endif !if &sequal #l0 "1" set-variable #l0 "section" !endif !if &sequal #l0 "11" set-variable #l0 "section*" !endif !if &sequal #l0 "2" set-variable #l0 "subsection" !endif !if &sequal #l0 "22" set-variable #l0 "subsection*" !endif !if &sequal #l0 "3" set-variable #l0 "subsubsection" !endif !if &sequal #l0 "33" set-variable #l0 "subsubsection*" !endif !if &sequal #l0 "4" set-variable #l0 "paragraph" !endif !if &sequal #l0 "5" set-variable #l0 "subparagraph" !endif set-variable #l1 @ml2 &cat "Optional label for " &cat #l0 " ?" "sec:" insert-string "\\" insert-string #l0 insert-string "{}" backward-char !if ¬ &seq #l1 "sec:" ; if not the default value, then insert \label command set-alpha-mark "\xff" forward-char insert-string "\n\\label{" insert-string #l1 insert-string "}" goto-alpha-mark "\xff" !endif ; store value for next run set-variable .default-section #l0 ml-write "[Inserted sectioning successfully]" !emacro