├── .gitignore ├── Contents ├── Clippings │ └── Latex.tex │ │ ├── 05)end │ │ ├── 05)begin…end │ │ ├── KOMAoptions │ │ ├── directives │ │ ├── set root │ │ └── set program │ │ ├── math accents │ │ ├── bar │ │ ├── vec │ │ ├── acute á │ │ ├── breve ă │ │ ├── check č │ │ ├── d1)dot ȧ │ │ ├── d2)ddot │ │ ├── d3)dddot │ │ ├── grave à │ │ ├── hat â │ │ ├── tilde ã │ │ ├── d4)ddddot │ │ ├── widehat │ │ ├── widetilde │ │ └── mathring å │ │ ├── mathematics │ │ ├── exponent │ │ ├── inverse │ │ ├── subscript │ │ ├── varinjlim │ │ ├── varprojlim │ │ ├── fraction │ │ ├── integral │ │ ├── summation │ │ ├── matrix A │ │ ├── matrix (A) │ │ ├── matrix [A] │ │ ├── matrix {A} │ │ ├── matrix |A| │ │ ├── matrix ‖A‖ │ │ ├── overbrace │ │ ├── underbrace │ │ ├── xleftarrow │ │ └── xrightarrow │ │ ├── text accents │ │ ├── acute ó │ │ ├── breve ŏ │ │ ├── caron ǒ │ │ ├── cedilla ç │ │ ├── grave ò │ │ ├── macron ō │ │ ├── ring ů │ │ ├── tie ⁀ │ │ ├── tilde ñ │ │ ├── umlaut ü │ │ ├── circumflex ô │ │ ├── dot above ġ │ │ ├── dot below ṃ │ │ ├── line below ḻ │ │ └── double accute ő │ │ ├── math fonts │ │ ├── mathbb │ │ ├── mathbf │ │ ├── mathcal │ │ ├── mathit │ │ ├── mathrm │ │ ├── mathscr │ │ ├── mathsf │ │ ├── mathtt │ │ └── mathfrak │ │ ├── mathtools │ │ ├── shortintertext │ │ ├── 00)mathtools package (preamble) │ │ ├── show number when referenced only │ │ ├── smashoperator (limit space, both sides) │ │ ├── smashoperator (limit space one side only) │ │ ├── eqref (reference an equation) │ │ ├── noeqref (like nocite for equations) │ │ ├── shortvdotswithin (centered vdots) │ │ ├── stretching arrows │ │ │ ├── xmapsto │ │ │ ├── xl)xLeftarrow │ │ │ ├── xr)xRightarrow │ │ │ ├── xhookrightarrow │ │ │ ├── xl)xLeftrightarrow │ │ │ └── xleftrightarrow │ │ ├── cases │ │ │ ├── cases* │ │ │ ├── dcases │ │ │ ├── dcases* │ │ │ ├── drcases │ │ │ ├── rcases │ │ │ ├── rcases* │ │ │ └── drcases* │ │ ├── prescript │ │ ├── tag formatting │ │ ├── Declare Paired Delimiter │ │ ├── adjustlimits (align limits vertically) │ │ └── Declare Paired Delimiter X │ │ ├── spacing │ │ ├── vspace │ │ ├── double spacing (preamble) │ │ ├── single spacing (preamble) │ │ ├── one-and-a-half spacing (preamble) │ │ ├── vspace stretch │ │ ├── double spacing (environment) │ │ ├── single spacing (environment) │ │ ├── one-and-a-half spacing (environment) │ │ ├── z5)No Margins │ │ └── skinny title (preamble) │ │ ├── font properties │ │ ├── 22)tiny │ │ ├── 28)small │ │ ├── 31)large │ │ ├── 32)Large │ │ ├── 34)LARGE │ │ ├── 36)huge │ │ ├── 38)Huge │ │ ├── 73)Bold │ │ ├── 76)Italic │ │ ├── 79)Medium │ │ ├── 90)Roman │ │ ├── 70)Emphasize │ │ ├── 82)Slanted │ │ ├── 85)Upright │ │ ├── 91)Sans Serif │ │ ├── 92)TypeWriter │ │ ├── 93)Small Caps │ │ ├── 24)scriptsize │ │ ├── 30)normalsize │ │ ├── 88)Underline │ │ └── 26)footnotesize │ │ ├── Theorems │ │ ├── lemma │ │ ├── proof │ │ ├── remark │ │ ├── example │ │ ├── theorem │ │ ├── corollary │ │ ├── definition │ │ ├── proposition │ │ ├── 00)Define unnumbered theorems │ │ └── 01)Define numbered theorems │ │ ├── math environments │ │ ├── 00)inline math │ │ ├── 01)display math │ │ ├── 50)intertext │ │ ├── 10)align │ │ ├── 10)equation │ │ ├── 30)align* │ │ ├── 30)equation* │ │ ├── 10)alignat │ │ ├── 10)gather │ │ ├── 30)gather* │ │ ├── 70)aligned │ │ ├── 30)alignat* │ │ ├── 50)split │ │ ├── 70)alignedat │ │ ├── 70)gathered │ │ ├── 10)multline │ │ ├── 30)multline* │ │ ├── cases │ │ ├── 10)equation+split │ │ └── 30)equation*+split │ │ ├── environments │ │ ├── abstract │ │ ├── quote │ │ ├── center │ │ ├── verbatim │ │ ├── flushright │ │ ├── itemize │ │ ├── document │ │ ├── enumerate │ │ ├── description │ │ ├── figure │ │ ├── minipage │ │ └── picture │ │ ├── amscd │ │ ├── CD │ │ ├── square diagram │ │ └── short exact sequence diagram │ │ ├── headers │ │ ├── watermark │ │ ├── fancypagestyle │ │ └── fancyhdr │ │ ├── zz)newcommand │ │ └── boxes │ │ ├── framebox │ │ ├── makebox │ │ └── parbox ├── Stationery │ ├── 04)Text.tex │ ├── 01)Math.tex │ ├── Labels.tex │ ├── Xe)Text (xelatex).tex │ ├── Envelope.tex │ ├── Xe)Math (xelatex).tex │ └── Letter.tex └── Resources │ ├── directives.py │ └── parse_log.py ├── AppleScriptSources ├── Clippings │ └── Latex.tex │ │ ├── environment.applescript │ │ ├── close-environment.applescript │ │ └── komaoptions.applescript ├── Scripts │ ├── 00)Typeset.applescript │ ├── 05)Open pdf.applescript │ └── Tools │ │ ├── Typeset inserting git info.applescript │ │ ├── 10)Show log warnings and errors.applescript │ │ ├── 05)Star-unstar environment.applescript │ │ ├── TeX Documentation Lookup.applescript │ │ ├── 05)Change environment.applescript │ │ ├── Declare Math Operator.applescript │ │ └── Check Latex Semantics.applescript ├── code snippets.txt └── Resources │ ├── environments-lib.applescript │ └── typeset-lib.applescript ├── history.txt └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.scpt 3 | *~ 4 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/05)end: -------------------------------------------------------------------------------- 1 | #script close-environment.scpt# 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/05)begin…end: -------------------------------------------------------------------------------- 1 | #script environment.scpt# 2 | #INDENT# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/KOMAoptions: -------------------------------------------------------------------------------- 1 | \KOMAoptions{#script komaoptions.scpt#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/directives/set root: -------------------------------------------------------------------------------- 1 | % !TEX root = #SELECTIONORINSERTION# 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/bar: -------------------------------------------------------------------------------- 1 | \bar{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/vec: -------------------------------------------------------------------------------- 1 | \vec{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/exponent: -------------------------------------------------------------------------------- 1 | ^{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/inverse: -------------------------------------------------------------------------------- 1 | #SELECT#^{-1}#INSERTION# 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/subscript: -------------------------------------------------------------------------------- 1 | _{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/acute ó: -------------------------------------------------------------------------------- 1 | \'{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/breve ŏ: -------------------------------------------------------------------------------- 1 | \u{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/caron ǒ: -------------------------------------------------------------------------------- 1 | \v{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/cedilla ç: -------------------------------------------------------------------------------- 1 | \c{#SELSTART#c#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/grave ò: -------------------------------------------------------------------------------- 1 | \`{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/macron ō: -------------------------------------------------------------------------------- 1 | \={#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/ring ů: -------------------------------------------------------------------------------- 1 | \r{#SELSTART#u#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/tie ⁀: -------------------------------------------------------------------------------- 1 | \t{#SELSTART#oo#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/tilde ñ: -------------------------------------------------------------------------------- 1 | \~{#SELSTART#n#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/umlaut ü: -------------------------------------------------------------------------------- 1 | \"{#SELSTART#u#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/acute á: -------------------------------------------------------------------------------- 1 | \acute{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/breve ă: -------------------------------------------------------------------------------- 1 | \breve{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/check č: -------------------------------------------------------------------------------- 1 | \check{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/d1)dot ȧ: -------------------------------------------------------------------------------- 1 | \dot{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/d2)ddot: -------------------------------------------------------------------------------- 1 | \ddot{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/d3)dddot: -------------------------------------------------------------------------------- 1 | \dddot{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/grave à: -------------------------------------------------------------------------------- 1 | \grave{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/hat â: -------------------------------------------------------------------------------- 1 | \hat{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/tilde ã: -------------------------------------------------------------------------------- 1 | \tilde{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathbb: -------------------------------------------------------------------------------- 1 | \mathbb{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathbf: -------------------------------------------------------------------------------- 1 | \mathbf{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathcal: -------------------------------------------------------------------------------- 1 | \mathcal{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathit: -------------------------------------------------------------------------------- 1 | \mathit{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathrm: -------------------------------------------------------------------------------- 1 | \mathrm{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathscr: -------------------------------------------------------------------------------- 1 | \mathscr{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathsf: -------------------------------------------------------------------------------- 1 | \mathsf{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathtt: -------------------------------------------------------------------------------- 1 | \mathtt{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/shortintertext: -------------------------------------------------------------------------------- 1 | \shortintertext{#SELECTIONORINSERTION#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/vspace: -------------------------------------------------------------------------------- 1 | \vspace{#PLACEHOLDERSTART#length#PLACEHOLDEREND#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/circumflex ô: -------------------------------------------------------------------------------- 1 | \^{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/dot above ġ: -------------------------------------------------------------------------------- 1 | \.{#SELSTART#g#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/dot below ṃ: -------------------------------------------------------------------------------- 1 | \d{#SELSTART#m#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/line below ḻ: -------------------------------------------------------------------------------- 1 | \b{#SELSTART#l#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/directives/set program: -------------------------------------------------------------------------------- 1 | % !TEX TS-program = #SELSTART#xelatex#SELEND# 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/22)tiny: -------------------------------------------------------------------------------- 1 | {\tiny #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/28)small: -------------------------------------------------------------------------------- 1 | {\small #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/31)large: -------------------------------------------------------------------------------- 1 | {\large #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/32)Large: -------------------------------------------------------------------------------- 1 | {\Large #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/34)LARGE: -------------------------------------------------------------------------------- 1 | {\LARGE #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/36)huge: -------------------------------------------------------------------------------- 1 | {\huge #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/38)Huge: -------------------------------------------------------------------------------- 1 | {\Huge #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/73)Bold: -------------------------------------------------------------------------------- 1 | \textbf{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/76)Italic: -------------------------------------------------------------------------------- 1 | \textit{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/79)Medium: -------------------------------------------------------------------------------- 1 | \textmd{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/90)Roman: -------------------------------------------------------------------------------- 1 | \textrm{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/d4)ddddot: -------------------------------------------------------------------------------- 1 | \ddddot{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/widehat: -------------------------------------------------------------------------------- 1 | \widehat{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/widetilde: -------------------------------------------------------------------------------- 1 | \widetilde{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math fonts/mathfrak: -------------------------------------------------------------------------------- 1 | \mathfrak{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/varinjlim: -------------------------------------------------------------------------------- 1 | \varinjlim{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/text accents/double accute ő: -------------------------------------------------------------------------------- 1 | \H{#SELSTART#o#SELEND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/70)Emphasize: -------------------------------------------------------------------------------- 1 | \emph{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/82)Slanted: -------------------------------------------------------------------------------- 1 | \textsl{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/85)Upright: -------------------------------------------------------------------------------- 1 | \textup{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/91)Sans Serif: -------------------------------------------------------------------------------- 1 | \textsf{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/92)TypeWriter: -------------------------------------------------------------------------------- 1 | \texttt{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/93)Small Caps: -------------------------------------------------------------------------------- 1 | \textsc{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math accents/mathring å: -------------------------------------------------------------------------------- 1 | \mathring{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/varprojlim: -------------------------------------------------------------------------------- 1 | \varprojlim{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/double spacing (preamble): -------------------------------------------------------------------------------- 1 | \usepackage{setspace} 2 | \doublespacing 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/single spacing (preamble): -------------------------------------------------------------------------------- 1 | \usepackage{setspace} 2 | \singlespacing 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/24)scriptsize: -------------------------------------------------------------------------------- 1 | {\scriptsize #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/30)normalsize: -------------------------------------------------------------------------------- 1 | {\normalsize #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/88)Underline: -------------------------------------------------------------------------------- 1 | \underline{#SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/fraction: -------------------------------------------------------------------------------- 1 | \frac{#SELECTIONORINSERTION#}{#INSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/integral: -------------------------------------------------------------------------------- 1 | \int_{#SELECTIONORINSERTION#}^{#INSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/summation: -------------------------------------------------------------------------------- 1 | \sum_{#SELECTIONORINSERTION#}^{#INSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/lemma: -------------------------------------------------------------------------------- 1 | \begin{lemma} 2 | #SELECTIONORINSERTION# 3 | \end{lemma} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/proof: -------------------------------------------------------------------------------- 1 | \begin{proof} 2 | #SELECTIONORINSERTION# 3 | \end{proof} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/font properties/26)footnotesize: -------------------------------------------------------------------------------- 1 | {\footnotesize #SELECTIONORINSERTION#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/00)inline math: -------------------------------------------------------------------------------- 1 | \(#SELECTIONORINSERTION#\)#INSERTION# 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/01)display math: -------------------------------------------------------------------------------- 1 | \[ 2 | #SELECTIONORINSERTION# 3 | \] 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/one-and-a-half spacing (preamble): -------------------------------------------------------------------------------- 1 | \usepackage{setspace} 2 | \onehalfspacing 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/remark: -------------------------------------------------------------------------------- 1 | \begin{remark} 2 | #SELECTIONORINSERTION# 3 | \end{remark} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/abstract: -------------------------------------------------------------------------------- 1 | \begin{abstract} #SELECTIONORPLACEHOLDER text# \end{abstract} #INDENT# -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/quote: -------------------------------------------------------------------------------- 1 | \begin{quote} 2 | #SELECTIONORINSERTION# 3 | \end{quote} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/00)mathtools package (preamble): -------------------------------------------------------------------------------- 1 | \usepackage{mathtools} % also loads amsmath 2 | 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/show number when referenced only: -------------------------------------------------------------------------------- 1 | \mathtoolsset{showonlyrefs,showmanualtags} 2 | 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/smashoperator (limit space, both sides): -------------------------------------------------------------------------------- 1 | \smashoperator{#SELECTIONORPLACEHOLDER#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/vspace stretch: -------------------------------------------------------------------------------- 1 | \vspace{\stretch{#PLACEHOLDERSTART#stretch factor#PLACEHOLDEREND#}} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/example: -------------------------------------------------------------------------------- 1 | \begin{example} 2 | #SELECTIONORINSERTION# 3 | \end{example} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/theorem: -------------------------------------------------------------------------------- 1 | \begin{theorem} 2 | #SELECTIONORINSERTION# 3 | \end{theorem} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/center: -------------------------------------------------------------------------------- 1 | \begin{center} 2 | #SELECTIONORINSERTION# 3 | \end{center} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/smashoperator (limit space one side only): -------------------------------------------------------------------------------- 1 | \smashoperator[l]{#SELECTIONORPLACEHOLDER#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/corollary: -------------------------------------------------------------------------------- 1 | \begin{corollary} 2 | #SELECTIONORINSERTION# 3 | \end{corollary} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/definition: -------------------------------------------------------------------------------- 1 | \begin{definition} 2 | #SELECTIONORINSERTION# 3 | \end{definition} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/verbatim: -------------------------------------------------------------------------------- 1 | \begin{verbatim} 2 | #SELECTIONORINSERTION# 3 | \end{verbatim} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/50)intertext: -------------------------------------------------------------------------------- 1 | \intertext{#SELECTIONORPLACEHOLDER text between aligned equations#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/proposition: -------------------------------------------------------------------------------- 1 | \begin{proposition} 2 | #SELECTIONORINSERTION# 3 | \end{proposition} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/amscd/CD: -------------------------------------------------------------------------------- 1 | \begin{equation*}\begin{CD} 2 | #SELECTIONORINSERTION# 3 | \end{CD}\end{equation*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/flushright: -------------------------------------------------------------------------------- 1 | \begin{flushright} 2 | #SELECTIONORINSERTION# 3 | \end{flushright} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/itemize: -------------------------------------------------------------------------------- 1 | \begin{itemize} 2 | \item #SELECTIONORINSERTION# 3 | \end{itemize} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/eqref (reference an equation): -------------------------------------------------------------------------------- 1 | ~\eqref{#PLACEHOLDERSTART#label#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/double spacing (environment): -------------------------------------------------------------------------------- 1 | \begin{doublespace} 2 | #SELECTIONORINSERTION# 3 | \end{doublespace} 4 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/single spacing (environment): -------------------------------------------------------------------------------- 1 | \begin{singlespace} 2 | #SELECTIONORINSERTION# 3 | \end{singlespace} 4 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/document: -------------------------------------------------------------------------------- 1 | \begin{document} 2 | 3 | #SELECTIONORINSERTION# 4 | 5 | \end{document} 6 | #INDENT# 7 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/enumerate: -------------------------------------------------------------------------------- 1 | \begin{enumerate} 2 | \item #SELECTIONORINSERTION# 3 | \end{enumerate} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/headers/watermark: -------------------------------------------------------------------------------- 1 | \usepackage{watermark} \watermark{ \setlength{\unitlength}{1in} \put(4,-8){\Huge watermark}} -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix A: -------------------------------------------------------------------------------- 1 | \begin{matrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{matrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/noeqref (like nocite for equations): -------------------------------------------------------------------------------- 1 | \noeqref{#PLACEHOLDERSTART#labels#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix (A): -------------------------------------------------------------------------------- 1 | \begin{pmatrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{pmatrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix [A]: -------------------------------------------------------------------------------- 1 | \begin{bmatrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{bmatrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix {A}: -------------------------------------------------------------------------------- 1 | \begin{Bmatrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{Bmatrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix |A|: -------------------------------------------------------------------------------- 1 | \begin{vmatrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{vmatrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/matrix ‖A‖: -------------------------------------------------------------------------------- 1 | \begin{Vmatrix} 2 | #SELSTART#a & b \\ 3 | c & d #SELEND# 4 | \end{Vmatrix} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/one-and-a-half spacing (environment): -------------------------------------------------------------------------------- 1 | \begin{onehalfspace} 2 | #SELECTIONORINSERTION# 3 | \end{onehalfspace} 4 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/zz)newcommand: -------------------------------------------------------------------------------- 1 | \newcommand{#PLACEHOLDERSTART#name#PLACEHOLDEREND#}{#PLACEHOLDERSTART#definition#PLACEHOLDEREND#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)align: -------------------------------------------------------------------------------- 1 | \begin{align} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{align} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)equation: -------------------------------------------------------------------------------- 1 | \begin{equation} 2 | #SELECTIONORPLACEHOLDER equation# 3 | \end{equation} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)align*: -------------------------------------------------------------------------------- 1 | \begin{align*} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{align*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)equation*: -------------------------------------------------------------------------------- 1 | \begin{equation*} 2 | #SELECTIONORPLACEHOLDER equation# 3 | \end{equation*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/overbrace: -------------------------------------------------------------------------------- 1 | \overbrace{#SELECTIONORINSERTION#}^{#PLACEHOLDERSTART#superscript#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/underbrace: -------------------------------------------------------------------------------- 1 | \underbrace{#SELECTIONORINSERTION#}_{#PLACEHOLDERSTART#subscript#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/shortvdotswithin (centered vdots): -------------------------------------------------------------------------------- 1 | \shortvdotswithin{#PLACEHOLDERSTART#character#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)alignat: -------------------------------------------------------------------------------- 1 | \begin{alignat} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{alignat} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)gather: -------------------------------------------------------------------------------- 1 | \begin{gather} 2 | #SELECTIONORPLACEHOLDER unaligned equations# 3 | \end{gather} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)gather*: -------------------------------------------------------------------------------- 1 | \begin{gather*} 2 | #SELECTIONORPLACEHOLDER unaligned equations# 3 | \end{gather*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/70)aligned: -------------------------------------------------------------------------------- 1 | \begin{aligned} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{aligned} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/description: -------------------------------------------------------------------------------- 1 | \begin{description} 2 | \item[#INSERTION#] #SELECTIONORINSERTION# 3 | \end{description} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)alignat*: -------------------------------------------------------------------------------- 1 | \begin{alignat*} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{alignat*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/50)split: -------------------------------------------------------------------------------- 1 | \begin{split} 2 | #SELECTIONORPLACEHOLDER split-line aligned equation# 3 | \end{split} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/70)alignedat: -------------------------------------------------------------------------------- 1 | \begin{alignedat} 2 | #SELECTIONORPLACEHOLDER aligned equations# 3 | \end{alignedat} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/70)gathered: -------------------------------------------------------------------------------- 1 | \begin{gathered} 2 | #SELECTIONORPLACEHOLDER unaligned equations# 3 | \end{gathered} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/xleftarrow: -------------------------------------------------------------------------------- 1 | \xleftarrow[#PLACEHOLDERSTART#below#PLACEHOLDEREND#]{#PLACEHOLDERSTART#above#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/z5)No Margins: -------------------------------------------------------------------------------- 1 | \usepackage[paperwidth=\textwidth + 50pt,paperheight=\textheight + 50pt,margin=25pt]{geometry} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathematics/xrightarrow: -------------------------------------------------------------------------------- 1 | \xrightarrow[#PLACEHOLDERSTART#below#PLACEHOLDEREND#]{#PLACEHOLDERSTART#above#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xmapsto: -------------------------------------------------------------------------------- 1 | \xmapsto[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)multline: -------------------------------------------------------------------------------- 1 | \begin{multline} 2 | #SELECTIONORPLACEHOLDER unaligned multiline equation# 3 | \end{multline} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)multline*: -------------------------------------------------------------------------------- 1 | \begin{multline*} 2 | #SELECTIONORPLACEHOLDER unaligned multiline equation# 3 | \end{multline*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xl)xLeftarrow: -------------------------------------------------------------------------------- 1 | \xLeftarrow[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/cases: -------------------------------------------------------------------------------- 1 | \begin{cases} 2 | #SELSTART#0 & \text{if $n$ is odd},\\ 3 | n & \text{if $n$ is even}#SELEND# 4 | \end{cases} 5 | #INDENT# 6 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xr)xRightarrow: -------------------------------------------------------------------------------- 1 | \xRightarrow[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/cases*: -------------------------------------------------------------------------------- 1 | \begin{cases*} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#text#PLACEHOLDEREND# 3 | \end{cases*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/dcases: -------------------------------------------------------------------------------- 1 | \begin{dcases} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#math#PLACEHOLDEREND# 3 | \end{dcases} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/dcases*: -------------------------------------------------------------------------------- 1 | \begin{dcases*} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#text#PLACEHOLDEREND# 3 | \end{dcases*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/drcases: -------------------------------------------------------------------------------- 1 | \begin{drcases} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#math#PLACEHOLDEREND# 3 | \end{drcases} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/rcases: -------------------------------------------------------------------------------- 1 | \begin{rcases} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#math#PLACEHOLDEREND# 3 | \end{rcases} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/rcases*: -------------------------------------------------------------------------------- 1 | \begin{rcases*} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#text#PLACEHOLDEREND# 3 | \end{rcases*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xhookrightarrow: -------------------------------------------------------------------------------- 1 | \xhookrightarrow[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xl)xLeftrightarrow: -------------------------------------------------------------------------------- 1 | \xLeftrightarrow[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/stretching arrows/xleftrightarrow: -------------------------------------------------------------------------------- 1 | \xleftrightarrow[#PLACEHOLDERSTART#sub#PLACEHOLDEREND#]{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/cases/drcases*: -------------------------------------------------------------------------------- 1 | \begin{drcases*} 2 | #PLACEHOLDERSTART#math#PLACEHOLDEREND# & #PLACEHOLDERSTART#text#PLACEHOLDEREND# 3 | \end{drcases*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/boxes/framebox: -------------------------------------------------------------------------------- 1 | \framebox[#PLACEHOLDERSTART#width#PLACEHOLDEREND#][#PLACEHOLDERSTART#alignment#PLACEHOLDEREND#]{#PLACEHOLDERSTART#text#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/boxes/makebox: -------------------------------------------------------------------------------- 1 | \makebox[#PLACEHOLDERSTART#width#PLACEHOLDEREND#][#PLACEHOLDERSTART#alignment#PLACEHOLDEREND#]{#PLACEHOLDERSTART#text#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/10)equation+split: -------------------------------------------------------------------------------- 1 | \begin{equation}\begin{split} 2 | #SELECTIONORPLACEHOLDER split aligned equation# 3 | \end{split}\end{equation} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/math environments/30)equation*+split: -------------------------------------------------------------------------------- 1 | \begin{equation*}\begin{split} 2 | #SELECTIONORPLACEHOLDER split aligned equation# 3 | \end{split}\end{equation*} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/prescript: -------------------------------------------------------------------------------- 1 | \prescript{#PLACEHOLDERSTART#sup#PLACEHOLDEREND#}{#PLACEHOLDERSTART#sub#PLACEHOLDEREND#}{#PLACEHOLDERSTART#command#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/figure: -------------------------------------------------------------------------------- 1 | \begin{figure}[htbp] 2 | \caption{#INSERTION#} 3 | \label{figure:#INSERTION#} 4 | \centering 5 | #SELECTIONORINSERTION# 6 | \end{figure} 7 | #INDENT# 8 | -------------------------------------------------------------------------------- /Contents/Stationery/04)Text.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,letterpaper]{article} 2 | 3 | \title{<##>} 4 | \author{<##>} 5 | 6 | \begin{document} 7 | \maketitle 8 | 9 | <##> 10 | 11 | \end{document} 12 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/amscd/square diagram: -------------------------------------------------------------------------------- 1 | \begin{equation*}\begin{CD} 2 | #INSERTION# @>>> #INSERTION#\\ 3 | @VVV @VVV\\ 4 | #INSERTION# @>>> #INSERTION# 5 | \end{CD}\end{equation*} 6 | #INDENT# 7 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/minipage: -------------------------------------------------------------------------------- 1 | \begin{minipage}[#PLACEHOLDERSTART#position#PLACEHOLDEREND#]{#PLACEHOLDERSTART#width#PLACEHOLDEREND#} 2 | #SELECTIONORINSERTION# 3 | \end{minipage} 4 | #INDENT# 5 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/tag formatting: -------------------------------------------------------------------------------- 1 | \newtagform{mytags}[#PLACEHOLDERSTART#font#PLACEHOLDEREND#]{#PLACEHOLDERSTART#before#PLACEHOLDEREND#}{#PLACEHOLDERSTART#after#PLACEHOLDEREND#} 2 | \usetagform{mytags} 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/Declare Paired Delimiter: -------------------------------------------------------------------------------- 1 | \DeclarePairedDelimiter{#PLACEHOLDERSTART#command name#PLACEHOLDEREND#}{#PLACEHOLDERSTART#left delimiter#PLACEHOLDEREND#}{#PLACEHOLDERSTART#right delimiter#PLACEHOLDEREND#} 2 | -------------------------------------------------------------------------------- /Contents/Stationery/01)Math.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,letterpaper]{amsart} 2 | \usepackage{graphicx,mathtools,fixltx2e,amssymb} 3 | 4 | \title{<##>} 5 | \author{<##>} 6 | 7 | \begin{document} 8 | \maketitle 9 | 10 | <##> 11 | 12 | \end{document} 13 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/headers/fancypagestyle: -------------------------------------------------------------------------------- 1 | \fancypagestyle{plain}{ %redefine style 2 | \fancyhf{} %clear 3 | \fancyhead[LE,RO]{This is a header} 4 | \fancyfoot[C]{\thepage} 5 | \renewcommand{\headrulewidth}{0pt} 6 | \renewcommand{\footrulewidth}{0pt}} 7 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/boxes/parbox: -------------------------------------------------------------------------------- 1 | \parbox[#PLACEHOLDERSTART#alignment#PLACEHOLDEREND#][#PLACEHOLDERSTART#height#PLACEHOLDEREND#][#PLACEHOLDERSTART#inner-alignment#PLACEHOLDEREND#]{#PLACEHOLDERSTART#width#PLACEHOLDEREND#}{#PLACEHOLDERSTART#text#PLACEHOLDEREND#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/adjustlimits (align limits vertically): -------------------------------------------------------------------------------- 1 | \adjustlimits{#PLACEHOLDERSTART#operator1#PLACEHOLDEREND#}_{#PLACEHOLDERSTART#limit1#PLACEHOLDEREND#}{#PLACEHOLDERSTART#operator2#PLACEHOLDEREND#}_{#PLACEHOLDERSTART#limit2#PLACEHOLDEREND#} 2 | #INLINE# 3 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/amscd/short exact sequence diagram: -------------------------------------------------------------------------------- 1 | \begin{equation*}\begin{CD} 2 | 0 @>>> #INSERTION# @>>> #INSERTION# @>>> #INSERTION# @>>> 0 \\ 3 | @. @VVV @VVV @VVV @. \\ 4 | 0 @>>> #INSERTION# @>>> #INSERTION# @>>> #INSERTION# @>>> 0 5 | \end{CD}\end{equation*} 6 | #INDENT# 7 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/00)Define unnumbered theorems: -------------------------------------------------------------------------------- 1 | \theoremstyle{definition} 2 | \newtheorem*{theorem}{Theorem} 3 | \newtheorem*{lemma}{Lemma} 4 | \newtheorem*{proposition}{Proposition} 5 | \newtheorem*{corollary}{Corollary} 6 | \newtheorem*{definition}{Definition} 7 | \newtheorem*{remark}{Remark} 8 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/spacing/skinny title (preamble): -------------------------------------------------------------------------------- 1 | % adjust the title to not leave space for author 2 | \makeatletter 3 | \renewcommand{\@maketitle}{ 4 | \newpage 5 | \begin{center}% 6 | {\LARGE\bf \@title \par}% 7 | %ifdef \@author 8 | {\large \@author \par}% 9 | %endif 10 | \end{center}% 11 | \par} \makeatother -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/Theorems/01)Define numbered theorems: -------------------------------------------------------------------------------- 1 | \theoremstyle{definition} 2 | \newtheorem{theorem}{Theorem} 3 | \newtheorem{lemma}[theorem]{Lemma} 4 | \newtheorem{proposition}[theorem]{Proposition} 5 | \newtheorem{corollary}[theorem]{Corollary} 6 | \newtheorem{definition}[theorem]{Definition} 7 | \newtheorem*{remark}{Remark} 8 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/mathtools/Declare Paired Delimiter X: -------------------------------------------------------------------------------- 1 | \DeclarePairedDelimiterX{#PLACEHOLDERSTART#command name#PLACEHOLDEREND#}[#PLACEHOLDERSTART#num args#PLACEHOLDEREND#]{#PLACEHOLDERSTART#left delimiter#PLACEHOLDEREND#}{#PLACEHOLDERSTART#right delimiter#PLACEHOLDEREND#}{#PLACEHOLDERSTART#between the delimiters#PLACEHOLDEREND#} 2 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/headers/fancyhdr: -------------------------------------------------------------------------------- 1 | \usepackage{fancyhdr} 2 | \pagestyle{fancy} 3 | #SELSTART#\fancyhead[LE,RO]{\slshape \rightmark} %these are all defaults 4 | \fancyhead[LO,RE]{\slshape \leftmark} %customize or delete 5 | \fancyfoot[C]{\thepage} 6 | \renewcommand{\headrulewidth}{0.4pt} 7 | \renewcommand{\footrulewidth}{0pt}#SELEND# 8 | -------------------------------------------------------------------------------- /Contents/Clippings/Latex.tex/environments/picture: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{#PLACEHOLDERSTART#length#PLACEHOLDEREND#} 2 | \begin{picture}(#PLACEHOLDERSTART#width#PLACEHOLDEREND#,#PLACEHOLDERSTART#height#PLACEHOLDEREND#)(#PLACEHOLDERSTART#x offset#PLACEHOLDEREND#,#PLACEHOLDERSTART#y offset#PLACEHOLDEREND#) 3 | \put(0,5){\circle*{0.5}} 4 | \put(1,5){\line(-1,-1){1}} 5 | \end{picture} 6 | #INDENT# 7 | -------------------------------------------------------------------------------- /Contents/Stationery/Labels.tex: -------------------------------------------------------------------------------- 1 | \documentclass{letter} 2 | \usepackage[avery5160label,nocapaddress]{envlab} 3 | % Envlab options. For more info run `texdoc elguide` 4 | % Label sizes: avery5160label, avery5161label, avery5162label, 5 | % avery5163label, avery5164label, avery5262label, herma4625label 6 | % Options: noprintbarcodes,alwaysbarcodes, 7 | \makelabels 8 | 9 | \begin{document} 10 | %\FirstLabel{row}{col} 11 | \startlabels 12 | \mlabel{}{% 13 | <#To Address#> 14 | } 15 | \end{document} 16 | -------------------------------------------------------------------------------- /Contents/Stationery/Xe)Text (xelatex).tex: -------------------------------------------------------------------------------- 1 | %!TEX TS-program = xelatex 2 | %!TEX encoding = UTF-8 Unicode 3 | \documentclass[11pt,letterpaper]{scrartcl} 4 | 5 | \usepackage{graphicx} 6 | \usepackage{fontspec} 7 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 8 | \setromanfont{Georgia}\setsansfont{Helvetica}\setmonofont{Monaco} 9 | \KOMAoptions{DIV=last} 10 | 11 | \setcounter{secnumdepth}{0} 12 | 13 | \title{<##>} 14 | \author{<##>} 15 | 16 | \begin{document} 17 | \maketitle 18 | 19 | <##> 20 | 21 | \end{document} 22 | -------------------------------------------------------------------------------- /Contents/Stationery/Envelope.tex: -------------------------------------------------------------------------------- 1 | \documentclass{letter} 2 | \usepackage[nocapaddress]{envlab} 3 | % Envlab options. For more info run `texdoc elguide` 4 | % Envelope sizes: executiveenvelope, bookletenvelope, 5 | % personalenvelope,c6envelope, c65envelope, c5envelope, dlenvelope 6 | % Options: norotateenvelopes,leftenvelopes,rightenvelopes 7 | % noprintbarcodes,alwaysbarcodes,noprintreturnaddress 8 | \makelabels 9 | 10 | \begin{document} 11 | \startlabels 12 | \mlabel{% 13 | <#From Address#> 14 | }{% 15 | <#To Address#> 16 | } 17 | \end{document} 18 | -------------------------------------------------------------------------------- /AppleScriptSources/Clippings/Latex.tex/environment.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | on run 4 | try 5 | set dialogResult to display dialog "Which environment?" default answer "" with title "New Latex environment" buttons {"Cancel", "Insert"} default button "Insert" cancel button "Cancel" 6 | on error 7 | return "" 8 | end try 9 | 10 | set environmentName to text returned of dialogResult 11 | 12 | return "\\begin{" & environmentName & "}" & return & tab & "#SELECTIONORINSERTION#" & return & "\\end{" & environmentName & "}" & return 13 | end run 14 | -------------------------------------------------------------------------------- /Contents/Stationery/Xe)Math (xelatex).tex: -------------------------------------------------------------------------------- 1 | %!TEX TS-program = xelatex 2 | %!TEX encoding = UTF-8 Unicode 3 | \documentclass[11pt,letterpaper]{scrartcl} 4 | 5 | %packages 6 | \usepackage{graphicx,amssymb} 7 | \usepackage{mathtools} %includes amsmath 8 | 9 | %math and other fonts 10 | \usepackage{mathspec} 11 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 12 | \setromanfont{Baskerville}\setsansfont{Helvetica Neue}\setmonofont{Monaco} 13 | \KOMAoptions{DIV=last} 14 | 15 | \title{<##>} 16 | \author{<##>} 17 | 18 | \begin{document} 19 | \maketitle 20 | 21 | <##> 22 | 23 | \end{document} 24 | -------------------------------------------------------------------------------- /Contents/Stationery/Letter.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt,letterpaper]{scrlttr2} 2 | \usepackage[english]{babel} 3 | 4 | %:Options 5 | %\KOMAoptions{parskip=full*,fromphone,fromrule,enlargefirstpage,subject=titled} 6 | \KOMAoptions{fromemail,fromalign=right,backaddress=false,foldmarks=TBp} 7 | 8 | % US-style signature line 9 | \let\raggedsignature\relax 10 | \makeatletter\@setplength{sigindent}{0.4\textwidth}\makeatother 11 | 12 | %:Return Address 13 | \setkomavar{fromname}{<#From Name#>} 14 | \setkomavar{fromaddress}{<#From Address#>} 15 | \setkomavar{fromemail}[]{<#From email#>} 16 | 17 | %:Date and Subject 18 | \setkomavar{date}{<#Date#>} 19 | \setkomavar{subject}{<#Subject#>} 20 | 21 | %:Start of letter 22 | \begin{document} 23 | \begin{letter}{<#To Address#>} 24 | \opening{<#Opening#>,} 25 | 26 | <#Text of letter#> 27 | 28 | 29 | \closing{Sincerely,} 30 | \end{letter} 31 | \end{document} 32 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/00)Typeset.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | on main() 4 | set typeset_lib_file to path_to_contents() & "Resources/typeset-lib.scpt" 5 | set typeset_lib to load script POSIX file typeset_lib_file 6 | tell typeset_lib to typeset without synctex and gitinfo 7 | end main 8 | 9 | 10 | -- Catch and display custom errors; exit silently on cancelled dialogs 11 | try 12 | main() 13 | on error eStr number eNum partial result rList from badObj to exptectedType 14 | if eNum = 5033 then 15 | display dialog eStr buttons {"OK"} with title "Error" default button 1 16 | else if eNum = 5088 then 17 | beep 18 | else if eNum is not -128 then 19 | error eStr number eNum partial result rList from badObj to exptectedType 20 | end if 21 | end try 22 | 23 | on path_to_contents() 24 | --- Returns path to "Contents" folder containing the current script 25 | local delims, split_string 26 | set delims to AppleScript's text item delimiters 27 | set AppleScript's text item delimiters to "/Contents/" 28 | set split_string to text items of POSIX path of (path to me) 29 | set AppleScript's text item delimiters to delims 30 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 31 | return (item 1 of split_string) & "/Contents/" 32 | end path_to_contents 33 | -------------------------------------------------------------------------------- /Contents/Resources/directives.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Search the top of a file for !TEX directives 4 | 5 | Usage: directives.py command1 [command2 [...]] filename 6 | 7 | Example: directives.py root program foo.tex 8 | 9 | Results are printed, one per line, in the order the arguments are listed. 10 | """ 11 | 12 | import re 13 | import sys 14 | 15 | def search(directive, head): 16 | """ 17 | Search for a directive, e.g. "% !TEX root = filename" 18 | """ 19 | try: 20 | m = re.search(r"%\s?!\s?TEX (TS-)?" + directive + 21 | r"\s?=\s?([^\s]*)", head) 22 | if m: 23 | return m.group(2) 24 | else: 25 | return "" 26 | except re.error as message: 27 | sys.stderr.write("Invalid regular expression: %s" % message) 28 | sys.exit(1) 29 | 30 | 31 | if len(sys.argv) == 1: 32 | sys.stderr.write("At least one argument is required") 33 | sys.exit(1) 34 | 35 | filename = sys.argv[-1] 36 | head = open(filename,'r').read(1000) 37 | d = dict() 38 | commands = sys.argv[1:-1] 39 | 40 | for c in commands: 41 | d[c] = search(c, head) 42 | 43 | if "root" in commands: 44 | if d["root"] == "": 45 | d["root"] = filename 46 | elif d["root"][0] != '/': 47 | d["root"] = filename[:filename.rfind('/')+1] + d["root"] 48 | 49 | for c in commands: 50 | print d[c] 51 | 52 | -------------------------------------------------------------------------------- /AppleScriptSources/Clippings/Latex.tex/close-environment.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | on main() 4 | set env_lib_file to path_to_contents() & "Resources/environments-lib.scpt" 5 | set env_lib to load script POSIX file env_lib_file 6 | tell env_lib to set {env_name, begin_loc, end_loc, cursor_loc, doc} to balance_environment without ending 7 | return "\\end{" & env_name & "}\r#INSERTION#" 8 | end main 9 | 10 | 11 | on run 12 | try 13 | return main() 14 | on error eStr number eNum partial result rList from badObj to exptectedType 15 | if eNum = 5033 then 16 | display dialog eStr buttons {"OK"} with title "Error" default button 1 17 | else if eNum = 5088 then 18 | return "\\end{#SELSTART#???#SELEND#}" 19 | else if eNum is not -128 then 20 | error eStr number eNum partial result rList from badObj to exptectedType 21 | end if 22 | end try 23 | end run 24 | 25 | on path_to_contents() 26 | --- Returns path to "Contents" folder containing the current script 27 | local delims, split_string 28 | set delims to AppleScript's text item delimiters 29 | set AppleScript's text item delimiters to "/Contents/" 30 | set split_string to text items of POSIX path of (path to me) 31 | set AppleScript's text item delimiters to delims 32 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 33 | return (item 1 of split_string) & "/Contents/" 34 | end path_to_contents 35 | -------------------------------------------------------------------------------- /history.txt: -------------------------------------------------------------------------------- 1 | Current version: 1.4.2 2 | 1.4.2 3 | Fix documentation 4 | 5 | 1.4.1 6 | Bug fix: filename extraction from log was picking up extra spaces 7 | 8 | 1.4 9 | Bug fix: spaces in file names 10 | Bug fix: ending a nested environment 11 | 12 | 1.3 13 | Bug fix: bad file reference in Typeset with git info 14 | Bug fix: end environment clipping works when cursor is at end of document 15 | Error handling for canceling clippings that have dialog boxes 16 | Error handling for files in zip files, on FTP servers, or without PDF 17 | Remove script to Install Stationery which is no longer necessary 18 | (Internal) Refactoring and consolidating 19 | 20 | 1.2 21 | Change "Insert Environment" script to "begin...end" clipping 22 | Change "Insert KOMAoptions" script to clipping 23 | New clipping: End environment 24 | New scripts: "Change environment" and "Star/unstar environment" 25 | Better PDF preview and Latex error reporting 26 | 27 | 1.1 28 | Bug fixes and interface cleanup in Typeset and Doc Lookup scripts 29 | New script "Insert Latex Environment" 30 | Adjust several clippings to handle pre-selected text 31 | Move template clippings to Stationery folder 32 | 33 | 1.0 34 | New script "Typeset Latex" removes the need for TeXShop 35 | New script "Open pdf" integrates with Skim and synctex 36 | Ability to use any pdf viewer 37 | New script "Show log warnings and errors" gives errors in a nice format 38 | Several new clippings 39 | Fixed some typos in clippings 40 | 41 | 0.1 42 | First version 43 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/05)Open pdf.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | 4 | on main() 5 | set typeset_lib_file to path_to_contents() & "Resources/typeset-lib.scpt" 6 | set typeset_lib to load script POSIX file typeset_lib_file 7 | 8 | tell typeset_lib 9 | set doc to get_front_BBEdit_doc() 10 | set filename to get_filename for doc 11 | end tell 12 | tell application "BBEdit" to set tex_position to startLine of selection 13 | tell typeset_lib 14 | set {root, tex} to extract_directives out of filename 15 | view_pdf of root with synctex given tex_program:tex, synctex_line:tex_position, synctex_file: filename 16 | end tell 17 | end main 18 | 19 | 20 | -- Catch and display custom errors; exit silently on cancelled dialogs 21 | try 22 | main() 23 | on error eStr number eNum partial result rList from badObj to exptectedType 24 | if eNum = 5033 then 25 | display dialog eStr buttons {"OK"} with title "Error" default button 1 26 | else if eNum = 5088 then 27 | beep 28 | else if eNum is not -128 then 29 | error eStr number eNum partial result rList from badObj to exptectedType 30 | end if 31 | end try 32 | 33 | on path_to_contents() 34 | --- Returns path to "Contents" folder containing the current script 35 | local delims, split_string 36 | set delims to AppleScript's text item delimiters 37 | set AppleScript's text item delimiters to "/Contents/" 38 | set split_string to text items of POSIX path of (path to me) 39 | set AppleScript's text item delimiters to delims 40 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 41 | return (item 1 of split_string) & "/Contents/" 42 | end path_to_contents 43 | 44 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/Typeset inserting git info.applescript: -------------------------------------------------------------------------------- 1 | (* by Nathan Grigg 2 | 3 | To use "Typeset inserting git info" script: 4 | 5 | 1. In your preamble, insert \providecommand{\RevisionInfo}{} 6 | 2. In the text, insert \RevisionInfo 7 | 8 | The result: 9 | 10 | - When you run normal latex, there will be no revision info 11 | - When you run this script, \RevisionInfo will be replaced with the info 12 | *) 13 | 14 | on main() 15 | set typeset_lib_file to path_to_contents() & "Resources/typeset-lib.scpt" 16 | set typeset_lib to load script POSIX file typeset_lib_file 17 | tell typeset_lib to typeset with gitinfo without synctex 18 | end main 19 | 20 | -- Catch and display custom errors; exit silently on cancelled dialogs 21 | try 22 | main() 23 | on error eStr number eNum partial result rList from badObj to exptectedType 24 | if eNum = 5033 then 25 | display dialog eStr buttons {"OK"} with title "Error" default button 1 26 | else if eNum = 5088 then 27 | beep 28 | else if eNum is not -128 then 29 | error eStr number eNum partial result rList from badObj to exptectedType 30 | end if 31 | end try 32 | 33 | on path_to_contents() 34 | --- Returns path to "Contents" folder containing the current script 35 | local delims, split_string 36 | set delims to AppleScript's text item delimiters 37 | set AppleScript's text item delimiters to "/Contents/" 38 | set split_string to text items of POSIX path of (path to me) 39 | set AppleScript's text item delimiters to delims 40 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 41 | return (item 1 of split_string) & "/Contents/" 42 | end path_to_contents 43 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/10)Show log warnings and errors.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | 4 | on main() 5 | set typeset_lib_file to path_to_contents() & "Resources/typeset-lib.scpt" 6 | set typeset_lib to load script POSIX file typeset_lib_file 7 | tell typeset_lib 8 | set doc to get_front_BBEdit_doc() 9 | set filename to get_filename for doc 10 | set err_list to parse_errors from filename with warnings 11 | end tell 12 | 13 | if length of err_list is 0 then 14 | display dialog "There are no errors or warnings" 15 | else 16 | tell application "BBEdit" to make new results browser with data err_list with properties {name:"Log Warnings and Errors"} 17 | end if 18 | end main 19 | 20 | -- Catch and display custom errors; exit silently on cancelled dialogs 21 | try 22 | main() 23 | on error eStr number eNum partial result rList from badObj to exptectedType 24 | if eNum = 5033 then 25 | display dialog eStr buttons {"OK"} with title "Error" default button 1 26 | else if eNum = 5088 then 27 | beep 28 | else if eNum is not -128 then 29 | error eStr number eNum partial result rList from badObj to exptectedType 30 | end if 31 | end try 32 | 33 | on path_to_contents() 34 | --- Returns path to "Contents" folder containing the current script 35 | local delims, split_string 36 | set delims to AppleScript's text item delimiters 37 | set AppleScript's text item delimiters to "/Contents/" 38 | set split_string to text items of POSIX path of (path to me) 39 | set AppleScript's text item delimiters to delims 40 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 41 | return (item 1 of split_string) & "/Contents/" 42 | end path_to_contents 43 | 44 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/05)Star-unstar environment.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | property delay_time : 0.2 4 | 5 | on main() 6 | set env_lib_file to path_to_contents() & "Resources/environments-lib.scpt" 7 | set env_lib to load script POSIX file env_lib_file 8 | tell env_lib to set {env_name, begin_loc, end_loc, cursor_loc, doc} to balance_environment with ending 9 | 10 | tell application "BBEdit" to select characters begin_loc thru end_loc of doc 11 | delay delay_time 12 | 13 | if last character of env_name is "*" then 14 | set new_env to text 1 through -2 of env_name 15 | else 16 | set new_env to env_name & "*" 17 | end if 18 | 19 | tell env_lib to change_environment(begin_loc, end_loc, doc, cursor_loc, new_env, env_name) 20 | end main 21 | 22 | -- Catch and display custom errors; exit silently on cancelled dialogs 23 | try 24 | main() 25 | on error eStr number eNum partial result rList from badObj to exptectedType 26 | if eNum = 5033 then 27 | display dialog eStr buttons {"OK"} with title "Error" default button 1 28 | else if eNum = 5088 then 29 | beep 30 | else if eNum is not -128 then 31 | error eStr number eNum partial result rList from badObj to exptectedType 32 | end if 33 | end try 34 | 35 | on path_to_contents() 36 | --- Returns path to "Contents" folder containing the current script 37 | local delims, split_string 38 | set delims to AppleScript's text item delimiters 39 | set AppleScript's text item delimiters to "/Contents/" 40 | set split_string to text items of POSIX path of (path to me) 41 | set AppleScript's text item delimiters to delims 42 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 43 | return (item 1 of split_string) & "/Contents/" 44 | end path_to_contents 45 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/TeX Documentation Lookup.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | property package_name : "" 4 | 5 | on main() 6 | -- get texbin from the typeset script 7 | set typeset_lib_file to path_to_contents() & "Resources/typeset-lib.scpt" 8 | set typeset_lib to load script POSIX file typeset_lib_file 9 | display dialog "Which package would you like documentation for?" default answer package_name 10 | set package_name to text returned of result 11 | get_tex_docs for package_name from typeset_lib's texbin 12 | end main 13 | 14 | on get_tex_docs for package_name from texbin 15 | try 16 | set stdout to do shell script "PATH=$PATH:" & quoted form of texbin & " ; texdoc " & (quoted form of package_name) 17 | on error number 127 18 | error "Shell command not found: texdoc" number 5033 19 | end try 20 | if stdout is not "" then error stdout number 5033 21 | end get_tex_docs 22 | 23 | try 24 | main() 25 | on error eStr number eNum partial result rList from badObj to exptectedType 26 | if eNum = 5033 then 27 | display dialog eStr buttons {"OK"} with title "Error" default button 1 28 | else if eNum = 5088 then 29 | beep 30 | else if eNum is not -128 then 31 | error eStr number eNum partial result rList from badObj to exptectedType 32 | end if 33 | end try 34 | 35 | on path_to_contents() 36 | --- Returns path to "Contents" folder containing the current script 37 | local delims, split_string 38 | set delims to AppleScript's text item delimiters 39 | set AppleScript's text item delimiters to "/Contents/" 40 | set split_string to text items of POSIX path of (path to me) 41 | set AppleScript's text item delimiters to delims 42 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 43 | return (item 1 of split_string) & "/Contents/" 44 | end path_to_contents 45 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/05)Change environment.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | on main() 4 | set env_lib_file to path_to_contents() & "Resources/environments-lib.scpt" 5 | set env_lib to load script POSIX file env_lib_file 6 | tell env_lib to set {env_name, begin_loc, end_loc, cursor_loc, doc} to balance_environment with ending 7 | 8 | tell application "BBEdit" to select characters begin_loc thru end_loc of doc 9 | 10 | try 11 | display dialog "Change " & env_name & " environment to:" default answer env_name with title "Change environment" 12 | on error number -128 13 | select insertion point before character cursor_loc of doc 14 | error number -128 15 | end try 16 | 17 | set new_env to text returned of result 18 | 19 | tell env_lib to change_environment(begin_loc, end_loc, doc, cursor_loc, new_env, env_name) 20 | end main 21 | 22 | -- Catch and display custom errors; exit silently on cancelled dialogs 23 | try 24 | main() 25 | on error eStr number eNum partial result rList from badObj to exptectedType 26 | if eNum = 5033 then 27 | display dialog eStr buttons {"OK"} with title "Error" default button 1 28 | else if eNum = 5088 then 29 | beep 30 | else if eNum is not -128 then 31 | error eStr number eNum partial result rList from badObj to exptectedType 32 | end if 33 | end try 34 | 35 | on path_to_contents() 36 | --- Returns path to "Contents" folder containing the current script 37 | local delims, split_string 38 | set delims to AppleScript's text item delimiters 39 | set AppleScript's text item delimiters to "/Contents/" 40 | set split_string to text items of POSIX path of (path to me) 41 | set AppleScript's text item delimiters to delims 42 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 43 | return (item 1 of split_string) & "/Contents/" 44 | end path_to_contents 45 | -------------------------------------------------------------------------------- /AppleScriptSources/Clippings/Latex.tex/komaoptions.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | on run 3 | set option_list to {"abstract=true Inserts the text “Abstract” before the abstract", "abstract=false", "appendixprefix=true Prefix appendix headings with “Appendix”", "appendixprefix=false", "bibliography=totoc Entry for bibliography in table of contents", "bibliography=totocnumbered Numbered entry for bibliography in toc", "captions=oneline Centers one-line captions", "captions=nooneline No special caption treatment", "captions=tableheading Captions are placed above tables", "captions=tablesignature Captions are placed below tables", "chapterprefix=true Prefix chapter headings with “Chapter”", "chapterprefix=false", "cleardoublepage=current Standard headings on blank pages", "cleardoublepage=plain Page number only on blank pages", "cleardoublepage=empty Nothing printed on blank pages", "footsepline=true Leave blank line before footer", "footsepline=false", "headings=small Small chapter and section headings", "headings=big", "headings=normal", "headsepline=true Leave blank line after header", "headsepline=false", "index=totoc Entry for index in table of contents", "listof=totoc Entry for list of figures in table of contents", "listof=flat No indents for lists of figures", "listof=graduated Indents for lists of figures", "numbers=enddot Include a dot after chapter numbers", "numbers=noenddot", "open=right Opens new chapters on right pages only", "open=any", "paper=letterpaper Letter sized paper", "paper=letterpaper,landscape Landscape letter sized paper", "parindent Indent paragraphs, no skip between pars", "parskip=full Full skip between pars, 1em free space", "parskip=full* Full skip between pars, quarter line free", "parskip=full+ Full skip between pars, third line free", "parskip=full- Full skip between pars, no free space", "parskip=half Half skip between pars, 1em free space", "parskip=half* Half skip between pars, quarter line free", "parskip=half+ Half skip between pars, third line free", "parskip=half- Half skip between pars, no free space", "titlepage=true Separate page for title", "titlepage=false", "toc=flat No indentation in the table of contents", "toc=graduated Varied indents in the table of contents"} 4 | 5 | -- display dialog 6 | set chosen_option to choose from list option_list with prompt "Select one or more KOMA Options." with multiple selections allowed 7 | if chosen_option is false then return "" 8 | 9 | 10 | -- extract command 11 | set AppleScript's text item delimiters to " " 12 | set command_list to {} 13 | repeat with option in chosen_option 14 | set command to text item 1 of option 15 | copy command to end of command_list 16 | end repeat 17 | 18 | -- make comma-separated list 19 | set AppleScript's text item delimiters to "," 20 | 21 | return (command_list as string) 22 | end run 23 | -------------------------------------------------------------------------------- /AppleScriptSources/code snippets.txt: -------------------------------------------------------------------------------- 1 | (* This file consists of snippets that are reused in several 2 | of the AppleScripts, but which are not big enough to warrant 3 | calling from an external library 4 | *) 5 | 6 | 7 | 8 | (* -------------------------------- 9 | path_to_contents handler 10 | 11 | returns path to "Contents" folder so that one 12 | script can reference another 13 | -------------------------------- *) 14 | 15 | on path_to_contents() 16 | --- Returns path to "Contents" folder containing the current script 17 | local delims, split_string 18 | set delims to AppleScript's text item delimiters 19 | set AppleScript's text item delimiters to "/Contents/" 20 | set split_string to text items of POSIX path of (path to me) 21 | set AppleScript's text item delimiters to delims 22 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 23 | return (item 1 of split_string) & "/Contents/" 24 | end path_to_contents 25 | 26 | 27 | (* -------------------------------- 28 | error handling wrapper 29 | 30 | catches my custom errors: 31 | 5033: Error with dialog box 32 | 5088: Error with beep 33 | 34 | also ignores -128 "User cancelled" 35 | 36 | all other errors are re-raised 37 | 38 | When debugging, it is useful to run main() directly so that 39 | AppleScript Editor will select the offending code when an 40 | error occurs. 41 | -------------------------------- *) 42 | 43 | -- Catch and display custom errors; exit silently on cancelled dialogs 44 | try 45 | main() 46 | on error eStr number eNum partial result rList from badObj to exptectedType 47 | if eNum = 5033 then 48 | display dialog eStr buttons {"OK"} with title "Error" default button 1 49 | else if eNum = 5088 then 50 | beep 51 | else if eNum is not -128 then 52 | error eStr number eNum partial result rList from badObj to exptectedType 53 | end if 54 | end try 55 | 56 | 57 | (* -------------------------------- 58 | get_front_BBEdit_doc handler 59 | 60 | returns front BBEdit document, raising an error if there isn't one 61 | -------------------------------- *) 62 | on get_front_BBEdit_doc() 63 | -- get front document, with error if there is none 64 | try 65 | tell application "BBEdit" to set doc to document 1 66 | on error number -1728 67 | error "There is no open BBEdit document" number 5033 68 | end try 69 | return doc 70 | end get_front_BBEdit_doc 71 | 72 | 73 | (* -------------------------------- 74 | get_filename handler 75 | 76 | returns the POSIX path to a BBEdit document, 77 | raising an error if in cannot get one 78 | -------------------------------- *) 79 | on get_filename for doc 80 | -- get filename from BBEdit document object, with error on missing value 81 | tell application "BBEdit" to set doc_file to file of doc 82 | if doc_file is missing value then error "Cannot access filename of document.\r\rCheck that it is saved on your local machine and not inside a zip file." number 5033 83 | return POSIX path of (doc_file as alias) 84 | end get_filename 85 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/Declare Math Operator.applescript: -------------------------------------------------------------------------------- 1 | -- Title for all the dialog boxes 2 | 3 | on main() 4 | set doc to get_front_BBEdit_doc() 5 | tell application "BBEdit" 6 | set cursor_position to selection 7 | set search_options to {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:true, match words:false, extend selection:false} 8 | 9 | --Find place where we are going to insert stuff 10 | -- search for other DeclareMathOperators 11 | set find_result to find "\\DeclareMathOperator" searching in text 1 of doc options search_options 12 | 13 | if found of find_result then 14 | set search_text to "\\DeclareMathOperator" 15 | set newline to "\r" 16 | else 17 | --can't find DeclareMathOperator, look for \begin{document} 18 | set find_result to find "\\begin{document}" searching in text 1 of doc options search_options 19 | if not found of find_result then error "I could not find the \\begin{document} command, so I do not know where the preamble ends. I am unable to continue." number 5033 20 | 21 | set search_text to "\\begin{document}" 22 | set newline to "\r\r" 23 | end if 24 | set preamble_pos to found object of find_result 25 | end tell 26 | 27 | -- ask for name of command 28 | display dialog "Name of command (e.g. \\sin)" with title "Declare Math Operator" default answer "" 29 | set command_name to text returned of result 30 | 31 | -- Check to make sure this math operator has not been defined in this document 32 | tell application "BBEdit" 33 | set find_result to find "\\DeclareMathOperator{" & command_name & "}" searching in text 1 of doc options search_options 34 | if found of find_result then error "The math operator " & command_name & " is already delcared." number 5033 35 | end tell 36 | 37 | -- Now get the text of the math operator 38 | -- use the command name with the first character removed as a guess 39 | try 40 | set guess to text 2 through end of command_name 41 | on error 42 | set guess to command_name 43 | end 44 | 45 | display dialog "Text of the math operator (e.g. sin)" with title "Declare Math Operator" default answer guess 46 | set command_text to text returned of result 47 | 48 | --do the replacement 49 | tell application "BBEdit" 50 | set insert_new to "\\DeclareMathOperator{" & command_name & "}{" & command_text & "}" & newline 51 | set insert_old to search_text 52 | set insert_length to length of insert_new 53 | set text of preamble_pos to insert_new & insert_old 54 | 55 | set cursor_offset to characterOffset of cursor_position 56 | set selection_length to length of cursor_position 57 | 58 | if selection_length = 0 then 59 | select insertion point before character (cursor_offset + insert_length) of doc 60 | else 61 | select characters (cursor_offset + insert_length) thru (cursor_offset + insert_length + selection_length - 1) of doc 62 | end if 63 | end tell 64 | end main 65 | 66 | -- Catch and display custom errors; exit silently on cancelled dialogs 67 | try 68 | main() 69 | on error eStr number eNum partial result rList from badObj to exptectedType 70 | if eNum = 5033 then 71 | display dialog eStr buttons {"OK"} with title "Error" default button 1 72 | else if eNum = 5088 then 73 | beep 74 | else if eNum is not -128 then 75 | error eStr number eNum partial result rList from badObj to exptectedType 76 | end if 77 | end try 78 | 79 | ------ Get information from BBEdit ------ 80 | on get_front_BBEdit_doc() 81 | -- get front document, with error if there is none 82 | try 83 | tell application "BBEdit" to set doc to document 1 84 | on error number -1728 85 | error "There is no open BBEdit document" number 5033 86 | end try 87 | return doc 88 | end get_front_BBEdit_doc 89 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # This package is not currently maintained 2 | 3 | - I haven't tested it on BBEdit 11 or higher. 4 | - I'm not planning to add new features or fix bugs. 5 | 6 | I am happy to accept contributions or fixes from the community. 7 | 8 | # Description 9 | 10 | A collection of scripts and clippings used to write Latex in BBEdit. 11 | 12 | # Installation 13 | 14 | ## Package only 15 | 16 | Download the package at , expand 17 | the archive, and drag the `Latex.bbpackage` package onto the BBEdit 18 | dock icon. 19 | 20 | Repeat the process to install an updated version of the package. 21 | 22 | Requires BBEdit 10.1 or newer. 23 | 24 | ## Full git repository 25 | 26 | The Latex.bbpackage project is hosted at . 27 | 28 | Clone the git repository from the command line 29 | 30 | $ cd Library/Application\ Support/BBEdit/ 31 | $ mkdir Packages # if it doesn't already exist 32 | $ cd Packages 33 | $ git clone git://github.com/nathangrigg/Latex.bbpackage.git 34 | 35 | Then compile the AppleScripts 36 | 37 | $ cd Latex.bbpackage 38 | $ ./build 39 | 40 | Since, at that point, you're already in the proper directory, you may want to 41 | open up the README markdown document. 42 | 43 | $ bbedit readme.md 44 | 45 | Use `git pull` to download an updated version of the package. You will 46 | need to run the `build` script after each update. 47 | 48 | # Contents 49 | 50 | ## Scripts 51 | 52 | The package include scripts to typeset Latex, view pdf (with forward search), 53 | change environment, star/unstar environment, show errors and warnings from log, 54 | and more. 55 | 56 | For more details, see the [Latex.bbpackage wiki][wiki]. 57 | 58 | ## Clippings 59 | 60 | The package includes clippings to insert an arbitrary environment, close the 61 | current environment, and many more. 62 | 63 | For details and descriptions of the clippings, 64 | see the [Latex.bbpackage wiki][wiki]. 65 | 66 | ## Stationery 67 | 68 | The package includes basic templates for math documents, text documents, 69 | envelopes, labels, letters, and xelatex documents. 70 | 71 | For more details, see the [Latex.bbpackage wiki][wiki]. 72 | 73 | 74 | # Acknowledgments 75 | 76 | The typeset script is made possible by code from the [rubber][rubber] 77 | project by Emmanuel Beffara. The "Check Latex Semantics" script is written 78 | by Ramón M. Figueroa-Centeno. 79 | 80 | 81 | # License 82 | 83 | (also known as the New BSD License) 84 | 85 | Copyright (c) 2011-2012, Nathan Grigg 86 | All rights reserved. 87 | 88 | Redistribution and use in source and binary forms, with or without 89 | modification, are permitted provided that the following conditions are met: 90 | 91 | * Redistributions of source code must retain the above copyright 92 | notice, this list of conditions and the following disclaimer. 93 | * Redistributions in binary form must reproduce the above copyright 94 | notice, this list of conditions and the following disclaimer in the 95 | documentation and/or other materials provided with the distribution. 96 | * Neither the name of this package nor the 97 | names of its contributors may be used to endorse or promote products 98 | derived from this software without specific prior written permission. 99 | 100 | This software is provided by the copyright holders and contributors "as is" and 101 | any express or implied warranties, including, but not limited to, the implied 102 | warranties of merchantability and fitness for a particular purpose are 103 | disclaimed. In no event shall Nathan Grigg be liable for any 104 | direct, indirect, incidental, special, exemplary, or consequential damages 105 | (including, but not limited to, procurement of substitute goods or services; 106 | loss of use, data, or profits; or business interruption) however caused and 107 | on any theory of liability, whether in contract, strict liability, or tort 108 | (including negligence or otherwise) arising in any way out of the use of this 109 | software, even if advised of the possibility of such damage. 110 | 111 | [rubber]: https://launchpad.net/rubber/ 112 | [wiki]: https://github.com/nathangrigg/Latex.bbpackage/wiki 113 | -------------------------------------------------------------------------------- /AppleScriptSources/Resources/environments-lib.applescript: -------------------------------------------------------------------------------- 1 | (* By Nathan Grigg 2 | Library balance a latex environment 3 | *) 4 | 5 | on balance_environment given ending:endBool 6 | (* "balance_environment with ending" finds the innermost 7 | environment containing the cursor 8 | "balance_envoronment wihtout ending" finds the innermost 9 | incomplete (i.e. without ending tag) environment 10 | containing the cursor 11 | both return {environment_name, begin_offset, end_offset, cursor_offset, document} 12 | end_offset will be missing value in without ending case 13 | *) 14 | 15 | set doc to get_front_BBEdit_doc() 16 | 17 | tell application "BBEdit" 18 | set cursor_loc to characterOffset of selection 19 | 20 | -- This is so if your cursor is \begin{equ|ation} it will still work. 21 | try 22 | set match_loc to find "\\w*{?\\w*\\*?}" searching in characters cursor_loc through -1 of doc options {search mode:grep} 23 | if found of match_loc and (characterOffset of found object of match_loc) is cursor_loc then 24 | set begin_loc to cursor_loc + (length of found object of match_loc) 25 | else 26 | set begin_loc to cursor_loc 27 | end if 28 | on error 29 | set begin_loc to cursor_loc 30 | end try 31 | 32 | set num_chars to length of text of doc 33 | if begin_loc > num_chars then set begin_loc to num_chars 34 | 35 | (* begin_loc tracks the first begin, which progress toward the beginning 36 | of the document as the outer loop progresses. 37 | nested_begin_loc tracks nested begins, which progress toward the 38 | end of the document as the inner loop progresses. 39 | end_loc tracks the nested ends 40 | *) 41 | repeat 42 | 43 | -- Search backwards to previous begin and extract environment name 44 | set match_begin to find "\\\\begin{([^}]*)}" searching in characters 1 through begin_loc of doc options {search mode:grep, backwards:true} 45 | 46 | if found of match_begin then 47 | set env to grep substitution of "\\1" 48 | set begin_loc to characterOffset of found object of match_begin 49 | set nested_begin_loc to begin_loc 50 | set end_loc to begin_loc 51 | else 52 | error "Cannot find a '\\begin' command" number 5088 53 | end if 54 | 55 | -- search for end environment, accounting for nesting 56 | -- continues until the next begin{env} is after the next end{env} 57 | repeat 58 | set match_nested_begin to find "\\\\begin{" & env & "}" searching in characters (nested_begin_loc + 1) through -1 of doc 59 | set match_end to find "\\\\end{" & env & "}" searching in characters (end_loc + 1) through -1 of doc 60 | 61 | if found of match_end then 62 | set end_loc to characterOffset of found object of match_end 63 | -- When looking for match without ending, don't go past cursor location 64 | if not endBool and end_loc > cursor_loc then 65 | return {env, begin_loc, missing value, cursor_loc, doc} 66 | end if 67 | else 68 | if endBool then 69 | error "Found '\\begin{" & env & "}' but no '\\end{" & env & "}'." number 5088 70 | else 71 | return {env, begin_loc, missing value, cursor_loc, doc} 72 | end if 73 | end if 74 | 75 | if found of match_nested_begin then 76 | set nested_begin_loc to characterOffset of found object of match_nested_begin 77 | else 78 | exit repeat 79 | end if 80 | 81 | if nested_begin_loc > end_loc then exit repeat 82 | end repeat 83 | 84 | set end_loc to end_loc + (length of found object of match_end) - 1 85 | 86 | if end_loc is greater than or equal to cursor_loc and cursor_loc is greater than or equal to begin_loc then exit repeat 87 | end repeat 88 | end tell 89 | if endBool then 90 | return {env, begin_loc, end_loc, cursor_loc, doc} 91 | else 92 | error "All environments are balanced" number 5088 93 | end if 94 | end balance_environment 95 | 96 | 97 | on change_environment(begin_loc, end_loc, doc, cursor_loc, new_env, old_env) 98 | set diff to (length of new_env) - (length of old_env) 99 | tell application "BBEdit" 100 | set characters (begin_loc + 7) through (begin_loc + 6 + (length of old_env)) of doc to new_env 101 | set characters (end_loc - (length of old_env) + diff) through (end_loc - 1 + diff) of doc to new_env 102 | 103 | -- move cursor to account for inserted characters 104 | select insertion point before character (cursor_loc + diff) of doc 105 | end tell 106 | end change_environment 107 | 108 | 109 | 110 | 111 | ------ Get information from BBEdit ------ 112 | on get_front_BBEdit_doc() 113 | -- get front document, with error if there is none 114 | try 115 | tell application "BBEdit" to set doc to document 1 116 | on error number -1728 117 | error "There is no open BBEdit document" number 5033 118 | end try 119 | return doc 120 | end get_front_BBEdit_doc 121 | -------------------------------------------------------------------------------- /AppleScriptSources/Scripts/Tools/Check Latex Semantics.applescript: -------------------------------------------------------------------------------- 1 | property chktexbin : "/usr/texbin/" 2 | 3 | (* 4 | ChkTeX for BBEdit 5 | Ramón M. Figueroa-Centeno 6 | http://www2.hawaii.edu/~ramonf 7 | 8 | Version: 1.2 9 | Date: October 12, 2007 10 | 11 | This AppleScript is released under a Creative Commons Attribution-ShareAlike License: 12 | 13 | 14 | Based on the CSS Syntax Check script for BBEdit by John Gruber: 15 | http://daringfireball.net/projects/csschecker/ 16 | 17 | Minor edits by Nathan Grigg 18 | *) 19 | 20 | on run 21 | my ChkteX() 22 | end run 23 | 24 | on ChkteX() 25 | tell application "BBEdit" 26 | try 27 | if not (on disk of active document of text window 1) then 28 | beep 29 | display dialog "You need to save your document!" buttons {"OK"} default button 1 with icon stop 30 | return 31 | end if 32 | on error 33 | beep 34 | return 35 | end try 36 | if (modified of active document of text window 1) then 37 | beep 38 | display dialog "You need to save changes to your document!" buttons {"Cancel", "Save"} default button 2 with icon caution 39 | end if 40 | set properties of active document of text window 1 to {line breaks:Unix} 41 | save active document of text window 1 42 | set texFile to file of active document of text window 1 43 | set texFileName to the name of the active document of text window 1 44 | if the source language of the active document of text window 1 is not "TeX" then 45 | display dialog "The source language of the document is not “TeX”!" buttons {"Sorry"} default button 1 with icon stop 46 | return 47 | end if 48 | 49 | (* 50 | if texFileName does not end with ".tex" then 51 | display dialog "Not a .tex file!" buttons {"Sorry"} default button 1 with icon stop 52 | return true 53 | end if 54 | *) 55 | 56 | end tell 57 | set texFileDir to do shell script "dirname " & the quoted form of the (POSIX path of texFile as string) 58 | 59 | if texFile is "" then return -- Don't proceed if we don't have a path to the file 60 | 61 | set newline to ASCII character 10 62 | 63 | (* ChkTeX can be told to use a custom format with the option -f followed by a string of these: 64 | 65 | %b String to print between fields (from -s option). 66 | %c Column position of error. 67 | %d Length of error (digit). 68 | %f Current file name. 69 | %i Turn on inverse printing mode. 70 | %I Turn off inverse printing mode. 71 | %k kind of error (warning, error, message). 72 | %l line number of error. 73 | %m Warning message. 74 | %n Warning number. 75 | %u An underlining line (like the one which appears when using “-v1”). 76 | %r Part of line in front of error (‘S’ - 1). 77 | %s Part of line which contains error (string). 78 | %t Part of line after error (‘S’ + 1). 79 | *) 80 | 81 | set command to "PATH=$PATH:" & quoted form of chktexbin & " ; cd " & quoted form of texFileDir & " ; " 82 | set command to command & "chktex -q -f \"%k%b%l%b%m%b%f%b%c%b%s" 83 | set command to command & newline & "\" " & quoted form of texFileName 84 | try 85 | set check_result to do shell script command 86 | on error err_text number err_num 87 | display dialog err_text 88 | end try 89 | 90 | set critic_error_list to {} 91 | 92 | tell application "BBEdit" 93 | if check_result is "" then 94 | set document_name to name of document of text window 1 95 | display alert "ChkTeX OK" message "No ChkTeX warnings were found in “" & document_name & "”." 96 | return 97 | end if 98 | 99 | -- Put together the results for the browser: 100 | repeat with err in (every paragraph of check_result) 101 | if (err as text) is not equal to "" then 102 | 103 | set old_delims to AppleScript's text item delimiters 104 | set AppleScript's text item delimiters to {":"} 105 | 106 | set kind_of_error to text item 1 of err 107 | if kind_of_error is "Error" then 108 | set err_kind to error_kind 109 | else if kind_of_error is "Warning" then 110 | set err_kind to warning_kind 111 | else if kind_of_error is "Message" then 112 | set err_kind to note_kind 113 | end if 114 | 115 | set line_num to text item 2 of err as integer 116 | 117 | set err_description to text item 3 of err 118 | 119 | set name_of_file to text item 4 of err as string 120 | 121 | set file_path to (texFileDir & "/" & name_of_file) 122 | 123 | -- The following breaks if we let BBEdit do it?! 124 | tell me to set the current_file to POSIX file file_path 125 | 126 | set error_string_length to length of (text item 6 of err as string) 127 | 128 | set before_error to (text item 5 of err as integer) 129 | 130 | set AppleScript's text item delimiters to old_delims 131 | 132 | -- We compute the offset of the line under consideration; if the line is in the open 133 | -- document we use BBEdit to get this offset, otherwise if the line is in an auxiliary 134 | -- file (loaded via \input) we use a shell script. The auxiliary file must have 135 | -- UNIX file endings (endline). 136 | 137 | if name_of_file = texFileName then 138 | set line_offset to (characterOffset of line line_num of the active document of text window 1) 139 | else 140 | tell me 141 | set line_offset to ((do shell script "head -n " & (line_num - 1) & " " & file_path & " | wc -m") as integer) + 1 142 | end tell 143 | end if 144 | 145 | set start_error to line_offset + before_error - 2 146 | set end_error to start_error + error_string_length 147 | 148 | set err_list_item to {result_kind:err_kind, result_file:current_file, result_line:line_num, message:err_description as text, start_offset:start_error, end_offset:end_error} 149 | 150 | copy err_list_item to end of critic_error_list 151 | end if 152 | end repeat 153 | 154 | try 155 | close window "ChkTeX Warnings" 156 | end try 157 | 158 | make new results browser with data critic_error_list with properties {name:"ChkTeX Warnings"} 159 | 160 | end tell 161 | 162 | end ChkteX 163 | -------------------------------------------------------------------------------- /AppleScriptSources/Resources/typeset-lib.applescript: -------------------------------------------------------------------------------- 1 | -- by Nathan Grigg 2 | 3 | -- User configurable variables 4 | property texbin : "/usr/texbin" 5 | property gitbin : "/usr/local/bin" 6 | property viewer : "Skim" 7 | 8 | ------ Main typeset script ------ 9 | 10 | on typeset given synctex:synctexBool, gitinfo:gitinfoBool 11 | (* typeset the front BBEdit document and display the pdf 12 | use "with synctex" to use forward search in Skim 13 | use "with gitinfo" to add latest git commit information 14 | *) 15 | 16 | set resource_path to path_to_contents() & "Resources/" 17 | set doc to get_front_BBEdit_doc() 18 | 19 | tell application "BBEdit" 20 | set tex_position to startLine of selection 21 | save doc 22 | if source language of doc is not "TeX" then 23 | display dialog "You are attempting to typeset a non-tex file." buttons {"Quit", "Continue"} default button "Quit" 24 | if button returned of result is "Quit" then return false 25 | end if 26 | end tell 27 | 28 | set filename to get_filename for doc 29 | set {root, tex_program} to extract_directives out of filename 30 | 31 | -- split folder from basename 32 | set delims to AppleScript's text item delimiters 33 | set AppleScript's text item delimiters to "/" 34 | set root_folder to "/" & (text items 1 thru -2 of root as string) 35 | set root_base to last text item of root 36 | set AppleScript's text item delimiters to delims 37 | 38 | -- get git info if requested 39 | if gitinfoBool then 40 | set script_suffix to "'" & (git_log for root_folder) & " \\input{\"" & root_base & "\"}'" 41 | else 42 | set script_suffix to quoted form of root_base 43 | end if 44 | 45 | -- run the pdflatex script 46 | try 47 | do shell script "PATH=$PATH:" & quoted form of texbin & " ; cd " & quoted form of root_folder & " ; " & tex_program & " -interaction=batchmode -synctex=1 " & script_suffix 48 | on error errMsg number errNum 49 | if errNum is 127 then command_not_found(tex_program) 50 | handle_latex_error from root given errMessage:errMsg 51 | return false 52 | end try 53 | 54 | view_pdf of root given synctex:synctexBool, tex_program:tex_program, synctex_line:tex_position, synctex_file:filename 55 | return true 56 | end typeset 57 | 58 | ------ Extract directives ------ 59 | 60 | on extract_directives out of filename 61 | --look in beginning of file for directives (e.g. "% !TEX program=xelatex") 62 | set resource_path to path_to_contents() & "Resources/" 63 | try 64 | set shell_result to do shell script quoted form of (resource_path & "directives.py") & " root program " & quoted form of filename 65 | on error errMsg 66 | error "Error extracting directives from file (python script directives.py)\r\r" & errMsg number 5033 67 | end try 68 | 69 | -- grab the root document name 70 | set filename to paragraph 1 of shell_result 71 | 72 | -- grab the latex engine 73 | set tex_program to paragraph 2 of shell_result 74 | if tex_program is "" then set tex_program to "pdflatex" 75 | 76 | return {filename, tex_program} 77 | end extract_directives 78 | 79 | 80 | ------ Git info ------ 81 | 82 | on git_log for folder_name 83 | -- get revision information from git 84 | try 85 | set git_info to do shell script "PATH=$PATH:" & quoted form of gitbin & "; cd " & quoted form of folder_name & "; " & "git log -1 --date=short --format=format:'\\newcommand{\\RevisionInfo}{Revision %h on %ad}'" 86 | on error errMsg number errNum 87 | if errNum is 127 then 88 | command_not_found("git") 89 | else if errNum is 128 then 90 | error errMsg number 5033 91 | else 92 | error errMsg number errNum 93 | end if 94 | end try 95 | return git_info 96 | end git_log 97 | 98 | ------ Latex error handling ------ 99 | 100 | on parse_errors from filename given warnings:warningsBool 101 | (* Parse errors from log associated to filename 102 | use "with warnings" to also parse warnings 103 | use "without warnings" to parse errors only 104 | *) 105 | set resource_path to path_to_contents() & "Resources/" 106 | -- parse errors from logfile and create a results browser 107 | set log_file to change_extension of filename into "log" 108 | 109 | if warningsBool then 110 | set parse_options to " --errors --warnings --refs --boxes " 111 | else 112 | set parse_options to " " 113 | end if 114 | 115 | try 116 | set shell_result to do shell script quoted form of (resource_path & "parse_log.py") & parse_options & (quoted form of log_file) 117 | on error 118 | error "Error parsing the log file. It may not exist (parse_log.py)" number 5033 119 | end try 120 | 121 | set err_list to {} 122 | repeat with err in (every paragraph of shell_result) 123 | if (err as text) is not equal to "" then 124 | try 125 | tell application "BBEdit" 126 | if (word 1 of err) is "Error" then 127 | set kind_of_result to error_kind 128 | else if (word 1 of err) is "Warning" then 129 | set kind_of_result to warning_kind 130 | else 131 | set kind_of_result to "Unknown" 132 | end if 133 | end tell 134 | on error 135 | set kind_of_result to "Unknown" 136 | end try 137 | 138 | if kind_of_result is not "Unknown" then 139 | set delims to AppleScript's text item delimiters 140 | set AppleScript's text item delimiters to {tab} 141 | set filename to text item 2 of err 142 | try 143 | set error_file to POSIX file filename as alias 144 | on error 145 | error "The log referenced an unknown file. (" & filename & ")" number 5033 146 | end try 147 | set error_line_str to text item 3 of err 148 | set error_description to text items 4 thru -1 of err as text 149 | set AppleScript's text item delimiters to delims 150 | try 151 | set error_line to error_line_str as integer 152 | on error 153 | set error_line to 0 154 | end try 155 | 156 | tell application "BBEdit" to set err_list_item to {result_kind:kind_of_result, result_line:error_line, message:error_description, result_file:error_file} 157 | copy err_list_item to end of err_list 158 | end if 159 | end if 160 | end repeat 161 | return err_list 162 | end parse_errors 163 | 164 | on handle_latex_error from filename given errMessage:errMsg 165 | -- handle an error in the latex shell command 166 | set err_list to parse_errors from filename without warnings 167 | if length of err_list is 0 then error "Latex command returned an error, but no errors are found in the log.\r\r" & errMsg number 5033 168 | 169 | tell application "BBEdit" 170 | set err to item 1 of err_list 171 | -- Errors that aren't line-based have a line number 0 172 | -- We don't want to move the cursor unless the there is a 173 | -- positive line 174 | if (result_line of err) > 0 then 175 | set button_text to "Go to Error" 176 | else 177 | set button_text to "OK" 178 | end if 179 | 180 | set err_dialog to display dialog "Error: " & message of err buttons {"See all errors", "Cancel", button_text} default button 3 with title "Error in typesetting" 181 | 182 | if button returned of err_dialog is "Go to Error" then 183 | set doc to open result_file of err 184 | -- special handling of undefined control sequence 185 | -- be a little careful to escape the backslash for BBEdit 186 | if message of err begins with "Undefined control sequence \\" then 187 | find ("\\\\" & text 29 through -2 of (message of err)) searching in line (result_line of err) of doc with selecting match 188 | if not found of result then tell doc to select line (result_line of err) 189 | else 190 | tell doc to select line (result_line of err) 191 | end if 192 | else if button returned of err_dialog is "See all errors" then 193 | make new results browser with data err_list with properties {name:"Log Warnings and Errors"} 194 | end if 195 | end tell 196 | end handle_latex_error 197 | 198 | ------ PDF subroutines ------ 199 | 200 | on view_pdf of filename given synctex:synctexBool, tex_program:tex, synctex_line:s_line, synctex_file:s_file 201 | (* View pdf in Skim or some other viewer 202 | The extension of filename doesn't matter; it is changed intelligently. 203 | Use tex_program:"pdflatex" to specify the tex program 204 | (this is used to determine if the extension is pdf or dvi) 205 | Use "with synctex" to use forward search (for Skim only) 206 | Use "given synctex_line:10, synctex_file:blah.tex" to give 207 | additional synctex information. 208 | Set the viewer property to use a different viewer program. 209 | If Skim is not installed but the viewer is set to Skim, it 210 | uses Preview instead. 211 | *) 212 | 213 | if {"tex", "etex", "eplain", "latex", "dviluatex", "dvilualatex", "xmltex", "jadetex", "mtex", "utf8mex", "cslatex", "csplain", "aleph", "lamed"} contains tex then 214 | set extension to "dvi" 215 | else 216 | set extension to "pdf" 217 | end if 218 | 219 | set pdf to change_extension of filename into extension 220 | -- test for existence of pdf file 221 | try 222 | POSIX file pdf as alias 223 | on error number -1700 224 | error "File " & pdf & " does not exist." number 5033 225 | end try 226 | 227 | if viewer is "Skim" then 228 | try 229 | -- check that Skim exists and get its path 230 | tell application "Finder" to set skim_path to POSIX path of (application file id "SKim" as alias) 231 | on error 232 | do shell script "open -g -a Preview " & quoted form of pdf 233 | return 234 | end try 235 | 236 | if synctexBool then 237 | try 238 | do shell script quoted form of skim_path & "Contents/SharedSupport/displayline -r -b -g " & s_line & " " & quoted form of pdf & " " & quoted form of s_file 239 | on error 240 | skim_reload(pdf) 241 | end try 242 | else 243 | skim_reload(pdf) 244 | end if 245 | else 246 | do shell script "open -g -a " & quoted form of viewer & " " & quoted form of pdf 247 | end if 248 | end view_pdf 249 | 250 | on skim_reload(pdf) 251 | -- this monstrosity allows the rest of the script to work even if Skim is not installed. 252 | do shell script "/usr/bin/osascript -e 'tell application \"Skim\"' -e 'set doc to open \"" & pdf & "\"' -e 'if doc is not missing value then revert doc' -e 'end tell'" 253 | end skim_reload 254 | 255 | ------ Get information from BBEdit ------ 256 | on get_front_BBEdit_doc() 257 | -- get front document, with error if there is none 258 | try 259 | tell application "BBEdit" to set doc to document 1 260 | on error number -1728 261 | error "There is no open BBEdit document" number 5033 262 | end try 263 | return doc 264 | end get_front_BBEdit_doc 265 | 266 | on get_filename for doc 267 | -- get filename from BBEdit document object, with error on missing value 268 | tell application "BBEdit" to set doc_file to file of doc 269 | if doc_file is missing value then error "Cannot access filename of document.\r\rCheck that it is saved on your local machine and not inside a zip file." number 5033 270 | return POSIX path of (doc_file as alias) 271 | end get_filename 272 | 273 | ------ String manipulation subroutines ------ 274 | 275 | on change_extension of filename into ext 276 | -- return filename with extension changed to ext 277 | set delims to AppleScript's text item delimiters 278 | set AppleScript's text item delimiters to "." 279 | set new_name to ((text items 1 thru -2 of filename) & ext) as string 280 | set AppleScript's text item delimiters to delims 281 | return new_name 282 | end change_extension 283 | 284 | on command_not_found(command_name) 285 | error "Shell command not found: " & command_name number 5033 286 | end command_not_found 287 | 288 | on path_to_contents() 289 | --- Returns path to "Contents" folder containing the current script 290 | local delims, split_string 291 | set delims to AppleScript's text item delimiters 292 | set AppleScript's text item delimiters to "/Contents/" 293 | set split_string to text items of POSIX path of (path to me) 294 | set AppleScript's text item delimiters to delims 295 | if length of split_string = 1 then error "This script must remain inside the Latex BBEdit package because it depends on other scripts in that package." number 5033 296 | return (item 1 of split_string) & "/Contents/" 297 | end path_to_contents 298 | -------------------------------------------------------------------------------- /Contents/Resources/parse_log.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This script derived from a piece of the rubber project 4 | # http://launchpad.net/rubber 5 | # (c) Emmanuel Beffara, 2002--2006 6 | # 7 | # Modified by Nathan Grigg, January 2012 8 | 9 | import re 10 | import string 11 | import sys 12 | import getopt 13 | 14 | #---- Log parser ----{{{1 15 | 16 | re_loghead = re.compile("This is [0-9a-zA-Z-]*") 17 | re_rerun = re.compile("LaTeX Warning:.*Rerun") 18 | re_file = re.compile("(\\((?P[^\n\t(){}]*[^ \n\t(){}])|\\))") 19 | re_badbox = re.compile(r"(Ov|Und)erfull \\[hv]box ") 20 | re_line = re.compile(r"(l\.(?P[0-9]+)( (?P.*))?$|<\*>)") 21 | re_cseq = re.compile(r".*(?P(\\|\.\.\.)[^ ]*) ?$") 22 | re_macro = re.compile(r"^(?P\\.*) ->") 23 | re_page = re.compile("\[(?P[0-9]+)\]") 24 | re_atline = re.compile( 25 | "( detected| in paragraph)? at lines? (?P[0-9]*)(--(?P[0-9]*))?") 26 | re_reference = re.compile("LaTeX Warning: Reference `(?P.*)' \ 27 | on page (?P[0-9]*) undefined on input line (?P[0-9]*)\\.$") 28 | re_label = re.compile("LaTeX Warning: (?PLabel .*)$") 29 | re_warning = re.compile( 30 | "(LaTeX|Package)( (?P.*))? Warning: (?P.*)$") 31 | re_online = re.compile("(; reported)? on input line (?P[0-9]*)") 32 | re_ignored = re.compile("; all text was ignored after line (?P[0-9]*).$") 33 | 34 | class LogCheck (object): 35 | """ 36 | This class performs all the extraction of information from the log file. 37 | For efficiency, the instances contain the whole file as a list of strings 38 | so that it can be read several times with no disk access. 39 | """ 40 | #-- Initialization {{{2 41 | 42 | def __init__ (self): 43 | self.lines = None 44 | 45 | def read (self, name): 46 | """ 47 | Read the specified log file, checking that it was produced by the 48 | right compiler. Returns true if the log file is invalid or does not 49 | exist. 50 | """ 51 | self.lines = None 52 | try: 53 | file = open(name) 54 | except IOError: 55 | return 2 56 | line = file.readline() 57 | if not line: 58 | file.close() 59 | return 1 60 | if not re_loghead.match(line): 61 | file.close() 62 | return 1 63 | self.lines = file.readlines() 64 | file.close() 65 | return 0 66 | 67 | #-- Process information {{{2 68 | 69 | def errors (self): 70 | """ 71 | Returns true if there was an error during the compilation. 72 | """ 73 | skipping = 0 74 | for line in self.lines: 75 | if line.strip() == "": 76 | skipping = 0 77 | continue 78 | if skipping: 79 | continue 80 | m = re_badbox.match(line) 81 | if m: 82 | skipping = 1 83 | continue 84 | if line[0] == "!": 85 | # We check for the substring "pdfTeX warning" because pdfTeX 86 | # sometimes issues warnings (like undefined references) in the 87 | # form of errors... 88 | 89 | if string.find(line, "pdfTeX warning") == -1: 90 | return 1 91 | return 0 92 | 93 | def run_needed (self): 94 | """ 95 | Returns true if LaTeX indicated that another compilation is needed. 96 | """ 97 | for line in self.lines: 98 | if re_rerun.match(line): 99 | return 1 100 | return 0 101 | 102 | #-- Information extraction {{{2 103 | 104 | def continued (self, line): 105 | """ 106 | Check if a line in the log is continued on the next line. This is 107 | needed because TeX breaks messages at 79 characters per line. We make 108 | this into a method because the test is slightly different in Metapost. 109 | """ 110 | return len(line) == 79 111 | 112 | def parse (self, errors=0, boxes=0, refs=0, warnings=0): 113 | """ 114 | Parse the log file for relevant information. The named arguments are 115 | booleans that indicate which information should be extracted: 116 | - errors: all errors 117 | - boxes: bad boxes 118 | - refs: warnings about references 119 | - warnings: all other warnings 120 | The function returns a generator. Each generated item is a dictionary 121 | that contains (some of) the following entries: 122 | - kind: the kind of information ("error", "box", "ref", "warning") 123 | - text: the text of the error or warning 124 | - code: the piece of code that caused an error 125 | - file, line, last, pkg: as used by Message.format_pos. 126 | """ 127 | if not self.lines: 128 | return 129 | last_file = None 130 | pos = [last_file] 131 | page = 1 132 | parsing = 0 # 1 if we are parsing an error's text 133 | skipping = 0 # 1 if we are skipping text until an empty line 134 | something = 0 # 1 if some error was found 135 | prefix = None # the prefix for warning messages from packages 136 | accu = "" # accumulated text from the previous line 137 | macro = None # the macro in which the error occurs 138 | cseqs = {} # undefined control sequences so far 139 | for line in self.lines: 140 | line = line[:-1] # remove the line feed 141 | 142 | # TeX breaks messages at 79 characters, just to make parsing 143 | # trickier... 144 | 145 | if not parsing and self.continued(line): 146 | accu += line 147 | continue 148 | line = accu + line 149 | accu = "" 150 | 151 | # Text that should be skipped (from bad box messages) 152 | 153 | if prefix is None and line == "": 154 | skipping = 0 155 | continue 156 | 157 | if skipping: 158 | continue 159 | 160 | # Errors (including aborted compilation) 161 | 162 | if parsing: 163 | if error == "Undefined control sequence.": 164 | # This is a special case in order to report which control 165 | # sequence is undefined. 166 | m = re_cseq.match(line) 167 | if m: 168 | seq = m.group("seq") 169 | if cseqs.has_key(seq): 170 | # This prevents reporting a sequence more than once 171 | error = None 172 | else: 173 | cseqs[seq] = None 174 | error = "Undefined control sequence %s." % m.group("seq") 175 | # Checks if the error is the definition of a macro 176 | m = re_macro.match(line) 177 | if m: 178 | macro = m.group("macro") 179 | # Extracts the line number 180 | m = re_line.match(line) 181 | if m: 182 | parsing = 0 183 | skipping = 1 184 | pdfTeX = string.find(line, "pdfTeX warning") != -1 185 | if error is not None and ((pdfTeX and warnings) or (errors and not pdfTeX)): 186 | if pdfTeX: 187 | d = { 188 | "kind": "warning", 189 | "pkg": "pdfTeX", 190 | "text": error[error.find(":")+2:] 191 | } 192 | else: 193 | d = { 194 | "kind": "error", 195 | "text": error 196 | } 197 | d.update( m.groupdict() ) 198 | m = re_ignored.search(error) 199 | if m: 200 | d["file"] = last_file 201 | if d.has_key("code"): 202 | del d["code"] 203 | d.update( m.groupdict() ) 204 | elif pos[-1] is None: 205 | d["file"] = last_file 206 | else: 207 | d["file"] = pos[-1] 208 | if macro is not None: 209 | d["macro"] = macro 210 | macro = None 211 | yield d 212 | elif line[0] == "!": 213 | error = line[2:] 214 | elif line[0:3] == "***": 215 | parsing = 0 216 | skipping = 1 217 | if errors: 218 | yield { 219 | "kind": "abort", 220 | "text": error, 221 | "why" : line[4:], 222 | "file": last_file 223 | } 224 | elif line[0:15] == "Type X to quit ": 225 | parsing = 0 226 | skipping = 0 227 | if errors: 228 | yield { 229 | "kind": "error", 230 | "text": error, 231 | "file": pos[-1] 232 | } 233 | continue 234 | 235 | if len(line) > 0 and line[0] == "!": 236 | error = line[2:] 237 | parsing = 1 238 | continue 239 | 240 | if line == "Runaway argument?": 241 | error = line 242 | parsing = 1 243 | continue 244 | 245 | # Long warnings 246 | 247 | if prefix is not None: 248 | if line[:len(prefix)] == prefix: 249 | text.append(string.strip(line[len(prefix):])) 250 | else: 251 | text = " ".join(text) 252 | m = re_online.search(text) 253 | if m: 254 | info["line"] = m.group("line") 255 | text = text[:m.start()] + text[m.end():] 256 | if warnings: 257 | info["text"] = text 258 | d = { "kind": "warning" } 259 | d.update( info ) 260 | yield d 261 | prefix = None 262 | continue 263 | 264 | # Undefined references 265 | 266 | m = re_reference.match(line) 267 | if m: 268 | if refs: 269 | d = { 270 | "kind": "warning", 271 | "text": _("Reference `%s' undefined.") % m.group("ref"), 272 | "file": pos[-1] 273 | } 274 | d.update( m.groupdict() ) 275 | yield d 276 | continue 277 | 278 | m = re_label.match(line) 279 | if m: 280 | if refs: 281 | d = { 282 | "kind": "warning", 283 | "file": pos[-1] 284 | } 285 | d.update( m.groupdict() ) 286 | yield d 287 | continue 288 | 289 | # Other warnings 290 | 291 | if line.find("Warning") != -1: 292 | m = re_warning.match(line) 293 | if m: 294 | info = m.groupdict() 295 | info["file"] = pos[-1] 296 | info["page"] = page 297 | if info["pkg"] is None: 298 | del info["pkg"] 299 | prefix = "" 300 | else: 301 | prefix = ("(%s)" % info["pkg"]) 302 | prefix = prefix.ljust(m.start("text")) 303 | text = [info["text"]] 304 | continue 305 | 306 | # Bad box messages 307 | 308 | m = re_badbox.match(line) 309 | if m: 310 | if boxes: 311 | mpos = { "file": pos[-1], "page": page } 312 | m = re_atline.search(line) 313 | if m: 314 | md = m.groupdict() 315 | for key in "line", "last": 316 | if md[key]: mpos[key] = md[key] 317 | line = line[:m.start()] 318 | d = { 319 | "kind": "warning", 320 | "text": line 321 | } 322 | d.update( mpos ) 323 | yield d 324 | skipping = 1 325 | continue 326 | 327 | # If there is no message, track source names and page numbers. 328 | 329 | last_file = self.update_file(line, pos, last_file) 330 | page = self.update_page(line, page) 331 | 332 | def get_errors (self): 333 | return self.parse(errors=1) 334 | def get_boxes (self): 335 | return self.parse(boxes=1) 336 | def get_references (self): 337 | return self.parse(refs=1) 338 | def get_warnings (self): 339 | return self.parse(warnings=1) 340 | 341 | def update_file (self, line, stack, last): 342 | """ 343 | Parse the given line of log file for file openings and closings and 344 | update the list `stack'. Newly opened files are at the end, therefore 345 | stack[1] is the main source while stack[-1] is the current one. The 346 | first element, stack[0], contains the value None for errors that may 347 | happen outside the source. Return the last file from which text was 348 | read (the new stack top, or the one before the last closing 349 | parenthesis). 350 | """ 351 | m = re_file.search(line) 352 | while m: 353 | if line[m.start()] == '(': 354 | last = m.group("file") 355 | stack.append(last) 356 | else: 357 | last = stack[-1] 358 | del stack[-1] 359 | line = line[m.end():] 360 | m = re_file.search(line) 361 | return last 362 | 363 | def update_page (self, line, before): 364 | """ 365 | Parse the given line and return the number of the page that is being 366 | built after that line, assuming the current page before the line was 367 | `before'. 368 | """ 369 | ms = re_page.findall(line) 370 | if ms == []: 371 | return before 372 | return int(ms[-1]) + 1 373 | 374 | 375 | # command line options 376 | 377 | def parse_options(cmdline): 378 | try: 379 | opts, args = getopt.getopt( 380 | cmdline, "h", ["boxes","errors","help","refs","warnings"]) 381 | except getopt.GetoptError, e: 382 | sys.stderr.write(e.msg + "\n") 383 | sys.exit(1) 384 | 385 | d = {"boxes": 0, "errors": 0, "refs": 0, "warnings": 0} 386 | 387 | # set a default option 388 | if len(opts) == 0: 389 | d["errors"] = 1 390 | for opt,arg in opts: 391 | if opt in ("-h","--help"): 392 | help() 393 | else: 394 | d[opt[2:]] = 1 395 | 396 | if len(args) != 1: 397 | sys.stderr.write("One log file is required\n") 398 | sys.exit(1) 399 | file = args[0] 400 | 401 | return d,file 402 | 403 | def help(): 404 | print ("""\ 405 | usage: rubber [options] logfile 406 | available options: 407 | --boxes display overfull/underfull box messages 408 | --errors display error messages 409 | --help display this message end exit 410 | --refs display missing reference messages 411 | --warnings display all other warnings 412 | """) 413 | sys.exit() 414 | 415 | # applescript compatible output 416 | 417 | def applescript_output(d,directory): 418 | out = [] 419 | if "kind" in d: 420 | if d["kind"] == "error": 421 | out.append("Error") 422 | else: 423 | out.append("Warning") 424 | else: 425 | return 426 | 427 | if "file" in d: 428 | file = d["file"] 429 | # convert relative path to absolute path 430 | if file[0] == "/": 431 | out.append(file) 432 | else: 433 | if file[:2] == "./": 434 | file = file[2:] 435 | out.append(directory + file) 436 | else: 437 | out.append("") 438 | 439 | 440 | if "line" in d and d["line"]: 441 | out.append(d["line"]) 442 | else: 443 | out.append("0") 444 | 445 | message = "" 446 | if "text" in d: 447 | message += d["text"] 448 | if "pkg" in d: 449 | message += " (Package %s) " % d["pkg"] 450 | if "page" in d: 451 | message += " (On page %d)" % d["page"] 452 | 453 | out.append(message) 454 | 455 | return "\t".join(out) 456 | 457 | 458 | if __name__ == "__main__": 459 | options,file = parse_options(sys.argv[1:]) 460 | directory = file[:file.rfind('/') + 1] 461 | check = LogCheck() 462 | check.read(file) 463 | for d in check.parse(errors=options["errors"], boxes=options["boxes"], 464 | refs=options["refs"], warnings=options["warnings"]): 465 | print applescript_output(d, directory) 466 | --------------------------------------------------------------------------------