├── .ert-runner
├── .gitignore
├── .travis.yml
├── COPYING
├── Makefile
├── README.md
├── README.org
├── calctex-contrib
└── calctex-contrib.el
├── calctex-pkg.el
├── calctex
├── Cask
├── Makefile
├── calctex.el
└── test
│ ├── calctex-test.el
│ ├── overlays-test.el
│ ├── resources
│ ├── 2a.tex
│ ├── 4a.tex
│ ├── joules.tex
│ └── pythag.tex
│ └── test-helper.el
├── demos
└── normal.gif
├── env.sh
├── install.sh
├── org-calctex
├── Cask
└── org-calctex.el
├── tangle_install.sh
├── test
├── calctex-contrib-test.el
├── calctex-test.el
├── org-calctex-test.el
├── resources
│ ├── 2a.dvi
│ ├── 2a.log
│ ├── 2a.png
│ ├── 2a.tex
│ ├── 2a_lowres.png
│ ├── 4a.log
│ ├── 4a.png
│ ├── 4a.tex
│ ├── alignstar.org
│ ├── auto
│ │ ├── 2a.el
│ │ ├── 2a_commented.el
│ │ ├── 4a.el
│ │ ├── f_x.el
│ │ ├── joules.el
│ │ └── pythag.el
│ ├── f_x.log
│ ├── joules.log
│ ├── joules.png
│ ├── joules.tex
│ ├── pythag.log
│ ├── pythag.png
│ ├── pythag.tex
│ └── test.org
└── test-helper.el
└── vendor
├── texd
├── ANNOUNCE
├── COPYING
├── FAQ
├── INSTALL
├── Makefile
├── README
├── dvichop.c
├── dvichop.sty
└── dviop.h
└── texmathp
└── texmathp.el
/.ert-runner:
--------------------------------------------------------------------------------
1 | -L .
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_Store
2 | demos/output/*
3 | *.mov
4 | ltximg/*
5 | /demos/.DS_Store
6 | /macos_install.sh
7 | /latex_install.sh
8 | *.aux
9 | resources/*.png
10 | resources/*.log
11 | *.DS_Store
12 | *.elc
13 | workdir*
14 | /vendor/texd
15 | **/.cask/
16 | *.png
17 | *.dvi
18 | *.log
19 | calctex/test/resources/auto
20 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: osx
2 | osx_image: xcode11
3 |
4 | cache:
5 | directories:
6 | - $HOME/Library/Caches/Homebrew
7 |
8 | addons:
9 | homebrew:
10 | update: true
11 | packages: []
12 |
13 | # The install script should be idempotent, so run it twice
14 | install:
15 | - ./install.sh
16 | - ./install.sh
17 |
18 | before_script:
19 | - source env.sh
20 |
21 | script: make test
22 |
23 | before_cache:
24 | - brew cleanup
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | calctex_images = $(addprefix calctex/test/resources/, 2a.png 4a.png 2a_lowres.png joules.png)
2 |
3 | clean :
4 | rm $(images)
5 |
6 | clean_workdir :
7 | rm -rf workdir* && mkdir workdir
8 |
9 | calctex/reference_images : $(calctex_images)
10 |
11 | calctex/test/resources/%.dvi : calctex/test/resources/%.tex
12 | pwd && latex -interaction nonstopmode -output-directory calctex/test/resources $<
13 |
14 | calctex/test/resources/%_lowres.png : calctex/test/resources/%.dvi
15 | dvipng $< -o $@ -T tight -D 150
16 |
17 | calctex/test/resources/%.png : calctex/test/resources/%.dvi
18 | dvipng -fg "rgb 0 0 0" -bg "rgb 1 1 1" -D 428 -T tight -o $@ $<
19 |
20 | test: calctex_test org_calctex_test calctex_contrib_test
21 |
22 | calctex_test: clean_workdir calctex/reference_images
23 | export TEXD_DIR=$$(cd vendor/texd; pwd); cd calctex; cask exec ert-runner test/calctex-test.el
24 |
25 | org_calctex_test: clean_workdir reference_images resources/test.org
26 | emacs -batch -L `pwd` -l color.el -l org.el -l ert.el -l test/test-helper.el -l test/org-calctex-test.el \
27 | --eval="(setq calctex-test-resources-dir \"$$(pwd)/resources\")" \
28 | --eval="(setq temporary-file-directory \"$$(pwd)/workdir\")" \
29 | -f toggle-debug-on-error \
30 | -f ert-run-tests-batch-and-exit
31 |
32 | calctex_contrib_test: calctex-contrib-test.el
33 | emacs -batch -L `pwd` -l ert.el -l calctex-contrib-test.el \
34 | -f ert-run-tests-batch-and-exit
35 |
36 | vendor/texd:
37 | cd vendor && git clone git@github.com:johnbcoughlin/texd.git
38 |
39 | vendor/texd/bin/dvichop: vendor/texd vendor/texd
40 | cd vendor/texd && mkdir -p bin && make dvichop && mv dvichop bin
41 |
42 | pkg: vendor/texd calctex.el calctex-pkg.el
43 | mkdir -p dist && tar -c -f dist/calctex-0.1 calctex.el calctex-pkg.el vendor/texd
44 |
45 |
46 | foo:
47 | export TEXD_DIR=$$(cd vendor/texd; pwd); echo $$TEXD_DIR
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Table of Contents
3 |
4 | 1. [CalcTeX](#orgc67ad3b)
5 | 1. [Why a WYSIWYG equation editor?](#orgc1b4053)
6 | 1. [A Tool of Thought](#orge78610c)
7 | 2. [No clicking](#org2d0c7db)
8 | 2. [Installation](#org03e079d)
9 | 1. [MacOS](#org2a81c17)
10 | 2. [LaTeX Packages](#org2f2223a)
11 | 3. [Usage](#org6636708)
12 | 1. [Integrating with documents](#org6271775)
13 | 2. [Display options](#org92480f0)
14 | 1. [Scaling](#orga73e863)
15 | 2. [Other](#org0c04504)
16 |
17 |
18 |
19 |
20 | # CalcTeX
21 |
22 | CalcTeX is a GNU Emacs minor mode that turns the [Emacs Calculator](https://www.gnu.org/software/emacs/manual/html_mono/calc.html) into a WYSIWYG
23 | editor for LaTeX formulas.
24 |
25 | 
26 |
27 |
28 |
29 |
30 | ## Why a WYSIWYG equation editor?
31 |
32 | Much [has](https://www.latex-project.org/about/) [been](https://www.quora.com/What-are-the-benefits-of-using-LaTeX-over-a-traditional-WYSIWYG-editor) [written](https://www.latex-project.org/about/) about the virtues of LaTeX *not* being a
33 | What-You-See-Is-What-You-Get markup system. These arguments, however convincing
34 | you find them, deal with LaTeX as a language for writing *text* in. I have never
35 | seen any kind of argument that the LaTeX development cycle is beneficial for
36 | writing mathematics.
37 |
38 | On the contrary, editing mathematics in LaTeX is, frankly, horrible. The
39 | experience bears zero resemblance to writing on the page. Whereas editing text
40 | on the computer is faster than handwriting, editing mathematics lags far behind
41 | in terms of user experience. Consider the difference between writing out an
42 | integral by hand,
43 |
44 | 
45 |
46 | and typing the LaTeX source for that same formula:
47 |
48 | The handwritten formula flows out of one's pen, and is a pleasure to write. On
49 | the other hand, nothing about the LaTeX source code is ergonomic. The backslash
50 | key is hard to reach, and long macro names and curly braces obscure the form of
51 | the equation. When typing the formula, there is no visual feedback to remind you
52 | where you are in the formula, alert you to any mistakes, or provide opportunity
53 | for reflecting on the content of what you're typing.
54 |
55 |
56 |
57 |
58 | ### A Tool of Thought
59 |
60 | A good editor should be a [tool of thought](http://www.eecg.toronto.edu/~jzhu/csc326/readings/iverson.pdf). Mathematical notation is the most
61 | refined and sophisticated tool of thought in human history. When writing math on
62 | the computer, we deserve an editor that **augments** the tool of mathematical
63 | notation, not one that suffocates it.
64 |
65 |
66 |
67 |
68 | ### No clicking
69 |
70 | WYSIWYG equation editors typically provide large menus of clickable buttons.
71 | A more powerful, Emacs-y alternative is key commands. CalcTeX is a display mode
72 | for Emacs Calc, which provides a huge number of key commands for manipulating
73 | equations.
74 |
75 |
76 |
77 |
78 | # Installation
79 |
80 |
81 |
82 |
83 | ## MacOS
84 |
85 | Ensure that you have the `latex` and `tlmgr` binaries installed and on
86 | your `$PATH`. The easiest way to install them is via the BasicTeX version of the
87 | TeXLive distribution, which installs all the binaries but omits 2.5GB of CTAN
88 | packages:
89 |
90 | brew cask install basictex
91 |
92 | You'll need to reload your shell to get the TeXLive binaries on your `PATH`.
93 | Check that you have them installed:
94 |
95 | latex -version
96 | tlmgr -version
97 |
98 |
99 |
100 |
101 | ## LaTeX Packages
102 |
103 | CalcTeX makes use of a few LaTeX packages. To run CalcTeX with the default
104 | settings, make sure that you have the following LaTeX packages installed:
105 |
106 | - `dvipng`
107 | - `xparse`
108 | - `xcolor`
109 | - `soul`
110 | - `adjustbox`
111 | - `collectbox`
112 | - `amsmath`
113 | - `amssymb`
114 | - `siunitx`
115 |
116 | If you are using TeXLive, you can install these with `tlmgr`:
117 |
118 | sudo tlmgr update --self
119 | sudo tlmgr install dvipng l3packages xcolor soul adjustbox collectbox amsmath amssymb siunitx
120 |
121 | You should now be able to run
122 |
123 | dvipng -version
124 |
125 | Alternatively, you can modify the value of the `calctex-format-latex-header`
126 | variable:
127 |
128 | (setq calctex-format-latex-header "...")
129 |
130 | However, be aware that doing so may compromise some facilities of CalcTeX,
131 | particularly its selection handling.
132 |
133 |
134 |
135 |
136 | # Usage
137 |
138 | To fire up calc, invoke `M-x calc`, or `C-x * c`. `calctex-mode` will toggle the
139 | minor mode in the calc buffer. You can type `'` for Algebraic entry mode, or
140 | type a numeral to begin a numeric entry. Refer to the [Calc manual](https://www.gnu.org/software/emacs/manual/html_mono/calc.html) for the many
141 | mathematical commands that are available.
142 |
143 |
144 |
145 |
146 | ## Integrating with documents
147 |
148 | CalcTeX is designed to be used in conjunction with calc's [Embedded Mode](https://www.gnu.org/software/emacs/manual//html_node/calc/Embedded-Mode.html#Embedded-Mode). In a
149 | LaTeX or Org buffer, move point to a LaTeX formula environment, and type
150 | `C-x * e` to invoke embedded mode. This will couple the top of the calc stack to the
151 | contents of the equation in the buffer you are editing.
152 |
153 |
154 |
155 |
156 | ## Display options
157 |
158 |
159 |
160 |
161 | ### Scaling
162 |
163 | CalcTeX currently offers two image format options: `png` and `imagemagick`. The
164 | default is `imagemagick`, unless your Emacs is compiled without support. To
165 | disable `imagemagick` even if it is supported:
166 |
167 | (setq calctex-iamgemagick-enabledp nil)
168 |
169 | Note that disabling `imagemagick` may have negative effects on the image quality
170 | on some displays: it disables downscaling the rendered image, which is sometimes
171 | necessary for a sharp image.
172 |
173 | The scaling factor applied by `imagemagick` is controlled by the variables
174 | `calctex-base-imagemagick-png-scaling` and `calctex-imagemagick-png-scaling`.
175 | The first controls the amount by which the "base" dots-per-inch value of
176 | `calctex-base-dpi` is increased, to improve resolution of the rendered image.
177 | This will have an immediate effect on the size of the overlay that appears in
178 | the buffer, which can be corrected by adjusting `calctex-imagemagick-png-scaling`.
179 |
180 |
181 |
182 |
183 | ### Other
184 |
185 | The variable `calctex-foreground-darken-percent` adjusts the foreground color of
186 | the rendered images. The default color is the same as the foreground color of
187 | the default face. This may appear too light for the font used by LaTeX, so it
188 | may be darkened or lightened to improve the match with the rest of the buffer.
189 |
190 |
--------------------------------------------------------------------------------
/README.org:
--------------------------------------------------------------------------------
1 | * CalcTeX
2 | CalcTeX is a GNU Emacs minor mode that turns the [[https://www.gnu.org/software/emacs/manual/html_mono/calc.html][Emacs Calculator]] into a WYSIWYG
3 | editor for LaTeX formulas.
4 |
5 | #+ATTR_ORG: :width 200/250/300/400/500/600
6 | [[file:demos/normal.gif]]
7 |
8 | ** Why a WYSIWYG equation editor?
9 | Much [[https://www.latex-project.org/about/][has]] [[https://www.quora.com/What-are-the-benefits-of-using-LaTeX-over-a-traditional-WYSIWYG-editor][been]] [[https://www.latex-project.org/about/][written]] about the virtues of LaTeX /not/ being a
10 | What-You-See-Is-What-You-Get markup system. These arguments, however convincing
11 | you find them, deal with LaTeX as a language for writing /text/ in. I have never
12 | seen any kind of argument that the LaTeX development cycle is beneficial for
13 | writing mathematics.
14 |
15 | On the contrary, editing mathematics in LaTeX is, frankly, horrible. The
16 | experience bears zero resemblance to writing on the page. Whereas editing text
17 | on the computer is faster than handwriting, editing mathematics lags far behind
18 | in terms of user experience. Consider the difference between writing out an
19 | integral by hand,
20 |
21 | #+ATTR_ORG: :width 200
22 | [[file:resources/cos_theta.png]]
23 |
24 | and typing the LaTeX source for that same formula:
25 |
26 | #+begin_src latex
27 | \int_0^\pi \cos\theta \,\mathrm{d}\theta
28 | #+end_src
29 |
30 | The handwritten formula flows out of one's pen, and is a pleasure to write. On
31 | the other hand, nothing about the LaTeX source code is ergonomic. The backslash
32 | key is hard to reach, and long macro names and curly braces obscure the form of
33 | the equation. When typing the formula, there is no visual feedback to remind you
34 | where you are in the formula, alert you to any mistakes, or provide opportunity
35 | for reflecting on the content of what you're typing.
36 |
37 | *** A Tool of Thought
38 | A good editor should be a [[http://www.eecg.toronto.edu/~jzhu/csc326/readings/iverson.pdf][tool of thought]]. Mathematical notation is the most
39 | refined and sophisticated tool of thought in human history. When writing math on
40 | the computer, we deserve an editor that *augments* the tool of mathematical
41 | notation, not one that suffocates it.
42 |
43 | *** No clicking
44 | WYSIWYG equation editors typically provide large menus of clickable buttons.
45 | A more powerful, Emacs-y alternative is key commands. CalcTeX is a display mode
46 | for Emacs Calc, which provides a huge number of key commands for manipulating
47 | equations.
48 |
49 | * Installation
50 | ** MacOS
51 | #+begin_src bash :tangle macos_install.sh :exports none
52 | #!/bin/bash
53 | #+end_src
54 |
55 | Ensure that you have the ~latex~ and ~tlmgr~ binaries installed and on
56 | your ~$PATH~. The easiest way to install them is via the BasicTeX version of the
57 | TeXLive distribution, which installs all the binaries but omits 2.5GB of CTAN
58 | packages:
59 |
60 | #+begin_src bash :tangle macos_install.sh
61 | brew cask install basictex
62 | #+end_src
63 |
64 | #+begin_src bash :tangle macos_env.sh :exports none
65 | export PATH=/Library/TeX/texbin:$PATH
66 | #+end_src
67 |
68 | #+begin_src bash :tangle macos_install.sh :exports none
69 | source macos_env.sh
70 | #+end_src
71 |
72 | You'll need to reload your shell to get the TeXLive binaries on your ~PATH~.
73 | Check that you have them installed:
74 | #+begin_src bash :tangle macos_install.sh
75 | latex -version
76 | tlmgr -version
77 | #+end_src
78 |
79 | ** LaTeX Packages
80 | #+begin_src bash :tangle latex_install.sh :exports none
81 | #!/bin/bash
82 | source env.sh
83 | #+end_src
84 |
85 | CalcTeX makes use of a few LaTeX packages. To run CalcTeX with the default
86 | settings, make sure that you have the following LaTeX packages installed:
87 | - ~dvipng~
88 | - ~xparse~
89 | - ~xcolor~
90 | - ~soul~
91 | - ~adjustbox~
92 | - ~collectbox~
93 | - ~amsmath~
94 | - ~amssymb~
95 | - ~siunitx~
96 |
97 | If you are using TeXLive, you can install these with ~tlmgr~:
98 |
99 | #+begin_src bash :tangle latex_install.sh
100 | sudo tlmgr update --self
101 | sudo tlmgr install dvipng l3packages xcolor soul adjustbox collectbox amsmath amssymb siunitx
102 | #+end_src
103 |
104 | You should now be able to run
105 |
106 | #+begin_src bash :tangle latex_install.sh
107 | dvipng -version
108 | #+end_src
109 |
110 | Alternatively, you can modify the value of the ~calctex-format-latex-header~
111 | variable:
112 |
113 | #+begin_src elisp
114 | (setq calctex-format-latex-header "...")
115 | #+end_src
116 |
117 | However, be aware that doing so may compromise some facilities of CalcTeX,
118 | particularly its selection handling.
119 |
120 | * Usage
121 | To fire up calc, invoke ~M-x calc~, or ~C-x * c~. ~calctex-mode~ will toggle the
122 | minor mode in the calc buffer. You can type ~'~ for Algebraic entry mode, or
123 | type a numeral to begin a numeric entry. Refer to the [[https://www.gnu.org/software/emacs/manual/html_mono/calc.html][Calc manual]] for the many
124 | mathematical commands that are available.
125 |
126 | ** Integrating with documents
127 | CalcTeX is designed to be used in conjunction with calc's [[https://www.gnu.org/software/emacs/manual//html_node/calc/Embedded-Mode.html#Embedded-Mode][Embedded Mode]]. In a
128 | LaTeX or Org buffer, move point to a LaTeX formula environment, and type
129 | ~C-x * e~ to invoke embedded mode. This will couple the top of the calc stack to the
130 | contents of the equation in the buffer you are editing.
131 |
132 | ** Display options
133 | *** Scaling
134 | CalcTeX currently offers two image format options: ~png~ and ~imagemagick~. The
135 | default is ~imagemagick~, unless your Emacs is compiled without support. To
136 | disable ~imagemagick~ even if it is supported:
137 |
138 | #+begin_src elisp
139 | (setq calctex-iamgemagick-enabledp nil)
140 | #+end_src
141 |
142 | Note that disabling ~imagemagick~ may have negative effects on the image quality
143 | on some displays: it disables downscaling the rendered image, which is sometimes
144 | necessary for a sharp image.
145 |
146 | The scaling factor applied by ~imagemagick~ is controlled by the variables
147 | ~calctex-base-imagemagick-png-scaling~ and ~calctex-imagemagick-png-scaling~.
148 | The first controls the amount by which the "base" dots-per-inch value of
149 | ~calctex-base-dpi~ is increased, to improve resolution of the rendered image.
150 | This will have an immediate effect on the size of the overlay that appears in
151 | the buffer, which can be corrected by adjusting ~calctex-imagemagick-png-scaling~.
152 | *** Other
153 | The variable ~calctex-foreground-darken-percent~ adjusts the foreground color of
154 | the rendered images. The default color is the same as the foreground color of
155 | the default face. This may appear too light for the font used by LaTeX, so it
156 | may be darkened or lightened to improve the match with the rest of the buffer.
157 |
--------------------------------------------------------------------------------
/calctex-pkg.el:
--------------------------------------------------------------------------------
1 | (define-package "calctex" "0.1" "WYSIWYG LaTeX equation editing with calc.el")
2 |
--------------------------------------------------------------------------------
/calctex/Cask:
--------------------------------------------------------------------------------
1 | (source gnu)
2 | (source melpa)
3 |
4 | (package "calctex" "0.1" "WYSIWYG LaTeX equation editing with calc.el")
5 | (files "calctex.el")
6 |
7 | (development
8 | (depends-on "f")
9 | (depends-on "ecukes")
10 | (depends-on "ert-runner")
11 | (depends-on "el-mock"))
12 |
--------------------------------------------------------------------------------
/calctex/Makefile:
--------------------------------------------------------------------------------
1 | images = $(addprefix test/resources/, 2a.png 4a.png 2a_lowres.png joules.png pythag.png)
2 |
3 | clean :
4 | rm $(images)
5 |
6 | clean_workdir :
7 | rm -rf workdir* && mkdir workdir
8 |
9 | reference_images : $(images)
10 |
11 | test/resources/%.dvi : test/resources/%.tex
12 | pwd && latex -interaction nonstopmode -output-directory test/resources $<
13 |
14 | test/resources/%_lowres.png : test/resources/%.dvi
15 | dvipng $< -o $@ -T tight -D 150
16 |
17 | test/resources/%.png : test/resources/%.dvi
18 | dvipng -fg "rgb 0 0 0" -bg "rgb 1 1 1" -D 428 -T tight -o $@ $<
19 |
20 | test: calctex_test org_calctex_test calctex_contrib_test
21 |
22 | calctex_test: clean_workdir reference_images
23 | emacs -batch -L `pwd` -l color.el -l ert.el -l test/test-helper.el -l test/calctex-test.el \
24 | --eval="(setq calctex-test-resources-dir \"$$(pwd)/resources\")" \
25 | --eval="(setq temporary-file-directory \"$$(pwd)/workdir\")" \
26 | -f toggle-debug-on-error \
27 | -f ert-run-tests-batch-and-exit
28 |
29 | org_calctex_test: clean_workdir reference_images resources/test.org
30 | emacs -batch -L `pwd` -l color.el -l org.el -l ert.el -l test/test-helper.el -l test/org-calctex-test.el \
31 | --eval="(setq calctex-test-resources-dir \"$$(pwd)/resources\")" \
32 | --eval="(setq temporary-file-directory \"$$(pwd)/workdir\")" \
33 | -f toggle-debug-on-error \
34 | -f ert-run-tests-batch-and-exit
35 |
36 | calctex_contrib_test: calctex-contrib-test.el
37 | emacs -batch -L `pwd` -l ert.el -l calctex-contrib-test.el \
38 | -f ert-run-tests-batch-and-exit
39 |
40 | vendor/texd/bin/dvichop: vendor/texd/dvichop.c vendor/texd/dviop.h
41 | cd vendor/texd && mkdir -p bin && make dvichop && mv dvichop bin
42 |
43 | pkg: vendor/texd calctex.el calctex-pkg.el
44 | mkdir -p dist && tar -c -f dist/calctex-0.1 calctex.el calctex-pkg.el vendor/texd
45 |
--------------------------------------------------------------------------------
/calctex/test/calctex-test.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright (C) 2019 John B Coughlin
4 |
5 | ;; This program is free software: you can redistribute it and/or modify
6 | ;; it under the terms of the GNU General Public License as published by
7 | ;; the Free Software Foundation, either version 3 of the License, or
8 | ;; (at your option) any later version.
9 |
10 | ;; This program is distributed in the hope that it will be useful,
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | ;; GNU General Public License for more details.
14 |
15 | ;; You should have received a copy of the GNU General Public License
16 | ;; along with this program. If not, see .
17 |
18 | (require 'calctex)
19 | (require 'ert)
20 |
21 | (defvar src-2a "\\[ 2a \\]")
22 |
23 | (ert-deftest test-imagemagick-disabled ()
24 | (calctex-mode 1)
25 | (let* ((calctex-imagemagick-enabled-p nil)
26 | (image-desc (funcall calctex-render-process src-2a)))
27 | (assert-image-descriptor-file-equals image-desc "2a_lowres.png")
28 | (should (equal (plist-get image-desc :type) 'png))
29 | (should (equal (plist-get image-desc :format) nil))
30 | (should (equal (plist-get image-desc :scale) nil))))
31 |
32 | (ert-deftest test-imagemagick-enabled ()
33 | (calctex-mode 1)
34 | (let* ((calctex-imagemagick-enabled-p t)
35 | (image-desc (funcall calctex-render-process src-2a)))
36 | (assert-image-descriptor-file-equals image-desc "2a.png")
37 | (should (equal (plist-get image-desc :type) 'imagemagick))
38 | (should (equal (plist-get image-desc :format) 'png))
39 | (should (equal (plist-get image-desc :scale)
40 | (/ calctex-imagemagick-png-scaling calctex-base-imagemagick-png-scaling)))))
41 |
42 | (ert-deftest creates-parents-of-image-cache ()
43 | (calctex-mode 1)
44 | (let ((calctex-latex-image-directory "./calctex-image-cache"))
45 | (assert-converts-latex-to-file src-2a "2a.png")))
46 |
47 | (ert-deftest renders-si ()
48 | (calctex-mode 1)
49 | (set-face-attribute 'default nil :foreground "black" :background "white")
50 | (assert-converts-latex-to-file
51 | "\\[ \\boxed{\\eta = \\frac{\\SI{6.27e8}{\\joule}}{\\SI{7.96e9}{\\joule}} = 0.0787} \\]"
52 | "joules.png"))
53 |
54 | (ert-deftest recovers-from-error ()
55 | (calctex-mode 1)
56 | (let ((err (should-error (funcall calctex-render-process "\\[ \\left( a^2 + b^2 = c^2 ) \\]"))))
57 | (should (string= (error-message-string err) "LaTeX Render Error. Renderer restarted.")))
58 | (assert-converts-latex-to-file "\\[ a^2 + b^{2} = c^2 \\]" "pythag.png")
59 | )
60 |
61 | (ert-deftest renders-2a ()
62 | (calctex-mode 1)
63 | (assert-converts-latex-to-file src-2a "2a.png"))
64 |
65 | (ert-deftest renders-multiple-sources ()
66 | (calctex-mode 1)
67 | (assert-converts-latex-to-file "\\[ 4a \\]" "4a.png")
68 | (assert-converts-latex-to-file "\\[ 4 a \\]" "4a.png")
69 | (assert-converts-latex-to-file "\\[ {4}{a} \\]" "4a.png")
70 | (assert-converts-latex-to-file "\\[ a^2 + b^{2} = c^2 \\]" "pythag.png")
71 | )
72 |
73 | (provide 'calctex-test)
74 |
--------------------------------------------------------------------------------
/calctex/test/overlays-test.el:
--------------------------------------------------------------------------------
1 | (require 'calctex)
2 | (require 'ert)
3 |
4 | (defun with-calc-test-harness (body)
5 | (set-face-attribute 'default nil :foreground "black" :background "white")
6 | (calc)
7 | (calc-reset 0)
8 | (with-current-buffer "*Calculator*"
9 | (let* ((tempdir-name (make-temp-name temporary-file-directory))
10 | (calctex-latex-image-directory tempdir-name))
11 | (make-directory calctex-latex-image-directory)
12 | (funcall body))))
13 |
14 | (defun nth-overlay (n)
15 | (let* ((ovs (overlays-in (point-min) (point-max)))
16 | (ov (nth n ovs)))
17 | ov))
18 |
19 | (defun overlay-display-property (ov prop)
20 | (let* ((disp (overlay-get ov 'display)))
21 | (plist-get (cdr disp) prop)))
22 |
23 | (defun assert-no-overlays ()
24 | (let* ((ovs (overlays-in (point-min) (point-max))))
25 | (should (= 0 (length ovs)))))
26 |
27 | (defun assert-nth-overlay-image-equals (n reference-image)
28 | (assert-overlay-image-equals
29 | (nth-overlay n)
30 | reference-image))
31 |
32 | (ert-deftest test-displays-image-correctly ()
33 | (with-calc-test-harness
34 | (lambda ()
35 | (calctex-mode 1)
36 | (execute-kbd-macro (kbd "' a "))
37 | (execute-kbd-macro (kbd "2 *"))
38 | (let ((ov (nth-overlay 0)))
39 | (assert-overlay-image-equals ov "2a.png")))))
40 |
41 | (ert-deftest test-changes-image-overlay-live ()
42 | (with-calc-test-harness
43 | (lambda ()
44 | (calctex-mode 1)
45 | (execute-kbd-macro (kbd "' a "))
46 | (execute-kbd-macro (kbd "2 *"))
47 | (assert-nth-overlay-image-equals 0 "2a.png")
48 | (execute-kbd-macro (kbd "2 *"))
49 | (assert-nth-overlay-image-equals 0 "4a.png"))))
50 |
51 | (ert-deftest test-turning-off-calctex-hides-overlays ()
52 | (with-calc-test-harness
53 | (lambda ()
54 | (calctex-mode 1)
55 | (execute-kbd-macro (kbd "' a "))
56 | (execute-kbd-macro (kbd "2 *"))
57 | (calctex-mode -1)
58 | (assert-no-overlays))))
59 |
60 | (ert-deftest test-switching-language-mode-hides-overlays ()
61 | (with-calc-test-harness
62 | (lambda ()
63 | (calctex-mode 1)
64 | (execute-kbd-macro (kbd "' a "))
65 | (execute-kbd-macro (kbd "2 *"))
66 | (execute-kbd-macro (kbd "d N"))
67 | (assert-no-overlays))))
68 |
69 | (ert-deftest test-multiple-overlays ()
70 | (with-calc-test-harness
71 | (lambda ()
72 | (calctex-mode 1)
73 | (execute-kbd-macro (kbd "' a "))
74 | (execute-kbd-macro (kbd "2 *"))
75 | (execute-kbd-macro (kbd ""))
76 | (execute-kbd-macro (kbd "2 *"))
77 | (assert-nth-overlay-image-equals 0 "2a.png")
78 | (assert-nth-overlay-image-equals 1 "4a.png")
79 | )))
80 |
--------------------------------------------------------------------------------
/calctex/test/resources/2a.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 |
17 | \documentclass{article}
18 | \usepackage[usenames]{color}
19 | \pagestyle{empty} % do not remove
20 | % The settings below are copied from fullpage.sty
21 | \setlength{\textwidth}{\paperwidth}
22 | \addtolength{\textwidth}{-3cm}
23 | \setlength{\oddsidemargin}{1.5cm}
24 | \addtolength{\oddsidemargin}{-2.54cm}
25 | \setlength{\evensidemargin}{\oddsidemargin}
26 | \setlength{\textheight}{\paperheight}
27 | \addtolength{\textheight}{-\headheight}
28 | \addtolength{\textheight}{-\headsep}
29 | \addtolength{\textheight}{-\footskip}
30 | \addtolength{\textheight}{-3cm}
31 | \setlength{\topmargin}{1.5cm}
32 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
33 | \usepackage{xcolor}
34 | %\setlength{\fboxsep}{0pt}
35 | \usepackage{soul}
36 | \usepackage{adjustbox}
37 | \usepackage{stix2}
38 |
39 | \usepackage{xparse}
40 |
41 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
42 | \begingroup\colorlet{currcolor}{.}%
43 | \IfValueTF{#1}
44 | {\textcolor[#1]{#2}}
45 | {\textcolor{#2}}
46 | {%
47 | #3% the nucleus
48 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
49 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
50 | }%
51 | \endgroup
52 | }
53 |
54 | \newcommand{\cmt}[1]{\ignorespaces}
55 |
56 | \begin{document}
57 | \definecolor{fg}{rgb}{0 0 0}
58 | \definecolor{bg}{rgb}{1 1 1}
59 | \pagecolor{bg}
60 | {\color{fg}
61 | \[ \cmt{2 a} 2 a \]
62 | }
63 | \end{document}
--------------------------------------------------------------------------------
/calctex/test/resources/4a.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 | \documentclass{article}
17 | \usepackage[usenames]{color}
18 | \pagestyle{empty} % do not remove
19 | % The settings below are copied from fullpage.sty
20 | \setlength{\textwidth}{\paperwidth}
21 | \addtolength{\textwidth}{-3cm}
22 | \setlength{\oddsidemargin}{1.5cm}
23 | \addtolength{\oddsidemargin}{-2.54cm}
24 | \setlength{\evensidemargin}{\oddsidemargin}
25 | \setlength{\textheight}{\paperheight}
26 | \addtolength{\textheight}{-\headheight}
27 | \addtolength{\textheight}{-\headsep}
28 | \addtolength{\textheight}{-\footskip}
29 | \addtolength{\textheight}{-3cm}
30 | \setlength{\topmargin}{1.5cm}
31 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
32 | \usepackage{xcolor}
33 | %\setlength{\fboxsep}{0pt}
34 | \usepackage{soul}
35 | \usepackage{adjustbox}
36 | \usepackage{stix2}
37 |
38 | \usepackage{xparse}
39 |
40 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
41 | \begingroup\colorlet{currcolor}{.}%
42 | \IfValueTF{#1}
43 | {\textcolor[#1]{#2}}
44 | {\textcolor{#2}}
45 | {%
46 | #3% the nucleus
47 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
48 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
49 | }%
50 | \endgroup
51 | }
52 |
53 | \begin{document}
54 | \[ 4a \]
55 | \end{document}
--------------------------------------------------------------------------------
/calctex/test/resources/joules.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage[usenames]{color}
3 | \pagestyle{empty} % do not remove
4 | % The settings below are copied from fullpage.sty
5 | \setlength{\textwidth}{\paperwidth}
6 | \addtolength{\textwidth}{-3cm}
7 | \setlength{\oddsidemargin}{1.5cm}
8 | \addtolength{\oddsidemargin}{-2.54cm}
9 | \setlength{\evensidemargin}{\oddsidemargin}
10 | \setlength{\textheight}{\paperheight}
11 | \addtolength{\textheight}{-\headheight}
12 | \addtolength{\textheight}{-\headsep}
13 | \addtolength{\textheight}{-\footskip}
14 | \addtolength{\textheight}{-3cm}
15 | \setlength{\topmargin}{1.5cm}
16 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
17 | \usepackage{xcolor}
18 | %\setlength{\fboxsep}{0pt}
19 | \usepackage{soul}
20 | \usepackage{adjustbox}
21 | \usepackage{siunitx}
22 | \usepackage{amsmath}
23 | \usepackage{stix2}
24 |
25 | \usepackage{xparse}
26 |
27 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
28 | \begingroup\colorlet{currcolor}{.}%
29 | \IfValueTF{#1}
30 | {\textcolor[#1]{#2}}
31 | {\textcolor{#2}}
32 | {%
33 | #3% the nucleus
34 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
35 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
36 | }%
37 | \endgroup
38 | }
39 |
40 | \newcommand{\cmt}[1]{\ignorespaces}
41 |
42 | \begin{document}
43 | \definecolor{fg}{rgb}{0 0 0}
44 | \definecolor{bg}{rgb}{1 1 1}
45 | \pagecolor{bg}
46 | {\color{fg}
47 | \[ \boxed{\eta = \frac{\SI{6.27e8}{\joule}}{\SI{7.96e9}{\joule}} = 0.0787} \]
48 | }
49 | \end{document}
50 |
--------------------------------------------------------------------------------
/calctex/test/resources/pythag.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 |
17 | \documentclass{article}
18 | \usepackage[usenames]{color}
19 | \pagestyle{empty} % do not remove
20 | % The settings below are copied from fullpage.sty
21 | \setlength{\textwidth}{\paperwidth}
22 | \addtolength{\textwidth}{-3cm}
23 | \setlength{\oddsidemargin}{1.5cm}
24 | \addtolength{\oddsidemargin}{-2.54cm}
25 | \setlength{\evensidemargin}{\oddsidemargin}
26 | \setlength{\textheight}{\paperheight}
27 | \addtolength{\textheight}{-\headheight}
28 | \addtolength{\textheight}{-\headsep}
29 | \addtolength{\textheight}{-\footskip}
30 | \addtolength{\textheight}{-3cm}
31 | \setlength{\topmargin}{1.5cm}
32 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
33 | \usepackage{xcolor}
34 | %\setlength{\fboxsep}{0pt}
35 | \usepackage{soul}
36 | \usepackage{adjustbox}
37 | \usepackage{stix2}
38 |
39 | \usepackage{xparse}
40 |
41 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
42 | \begingroup\colorlet{currcolor}{.}%
43 | \IfValueTF{#1}
44 | {\textcolor[#1]{#2}}
45 | {\textcolor{#2}}
46 | {%
47 | #3% the nucleus
48 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
49 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
50 | }%
51 | \endgroup
52 | }
53 |
54 | \begin{document}
55 | \definecolor{fg}{rgb}{0 0 0}
56 | \definecolor{bg}{rgb}{1 1 1}
57 | \pagecolor{bg}
58 | {\color{fg}
59 | \[ a^2 + b^2 = c^2 \]
60 | }
61 | \end{document}
--------------------------------------------------------------------------------
/calctex/test/test-helper.el:
--------------------------------------------------------------------------------
1 | ;;; test-helper.el --- Helpers for calctex-test.el
2 |
3 | (setq debug-on-error t)
4 | (setq debug-on-quit t)
5 |
6 | (set-face-attribute 'default nil :foreground "black" :background "white")
7 |
8 | (defvar calctex-test-resources-dir nil "The directory where test resources live")
9 |
10 | (setq calctex-dvichop-sty (format "%s/dvichop" (getenv "TEXD_DIR")))
11 | (setq calctex-dvichop-bin (format "%s/bin/dvichop" (getenv "TEXD_DIR")))
12 |
13 | (setq calctex-test-resources-dir (expand-file-name "resources" (file-name-directory load-file-name)))
14 |
15 | (defun resource-file (name)
16 | (expand-file-name name calctex-test-resources-dir))
17 |
18 | (defun assert-converts-latex-to-file (src reference-image)
19 | (assert-image-descriptor-file-equals
20 | (funcall calctex-render-process src)
21 | reference-image))
22 |
23 | (defun assert-overlay-image-equals (ov reference-image)
24 | (let* ((disp (overlay-get ov 'display)))
25 | (progn
26 | (message "%s" disp)
27 | (assert-image-descriptor-file-equals (cdr disp) reference-image)))
28 | )
29 |
30 | (defun assert-image-descriptor-file-equals (img reference-image)
31 | (let ((actual-file (plist-get img :file)))
32 | (assert-image-equals actual-file reference-image)))
33 |
34 | (defun assert-image-equals (actual expected)
35 | (let* ((file-comp (format
36 | "if (( $(echo \"0.03 > $(compare -metric DSSIM %s %s diff.png 2>&1)\" | bc -l) )); then exit 0; else exit 1; fi"
37 | actual (resource-file expected)))
38 | (equality (shell-command file-comp)))
39 | (progn
40 | (unless (= equality 0)
41 | (message "ran: %s" file-comp))
42 | (should (= equality 0)))))
43 |
44 | ;;; test-helper.el ends here
45 |
--------------------------------------------------------------------------------
/demos/normal.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/demos/normal.gif
--------------------------------------------------------------------------------
/env.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$TRAVIS_OS_NAME" == "osx" ]; then
4 | source macos_env.sh
5 | fi
6 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -ex
4 |
5 | brew tap d12frosted/emacs-plus
6 | brew install emacs-plus --without-spacemacs-icon
7 |
8 | emacs --batch -l org README.org -f org-babel-tangle
9 |
10 | chmod +x macos_install.sh
11 | chmod +x latex_install.sh
12 |
13 | if [ "$TRAVIS_OS_NAME" == "osx" ]; then
14 | ./macos_install.sh
15 | fi
16 |
17 | ./latex_install.sh
18 |
--------------------------------------------------------------------------------
/org-calctex/Cask:
--------------------------------------------------------------------------------
1 | (source gnu)
2 | (source melpa)
3 |
4 | (package "calctex" "0.1" "WYSIWYG LaTeX equation editing with calc.el")
5 | (files "calctex.el"
6 | "org-calctex.el"
7 | "calctex-contrib.el"
8 | ("vendor" ("texd" "vendor/texd/bin/dvichop" "vendor/texd/dvichop.sty")))
9 |
10 | (depends-on "posframe")
11 | (depends-on "hydra")
12 | (depends-on "cdlatex")
13 |
14 | (development
15 | (depends-on "f")
16 | (depends-on "ecukes")
17 | (depends-on "ert-runner")
18 | (depends-on "el-mock"))
19 |
--------------------------------------------------------------------------------
/org-calctex/org-calctex.el:
--------------------------------------------------------------------------------
1 | ;;; org-calctex.el --- CalcTeX integration with Org mode -*- lexical-binding: t; -*-
2 |
3 | ;; Author: Jack Coughlin
4 | ;; URL: https://github.com/johnbcoughlin/calctex
5 | ;; Version: 0.1
6 | ;; Package-Requires: ((emacs "24.4"))
7 |
8 | ;; Copyright (C) 2019 John B Coughlin
9 |
10 | ;; This program is free software: you can redistribute it and/or modify
11 | ;; it under the terms of the GNU General Public License as published by
12 | ;; the Free Software Foundation, either version 3 of the License, or
13 | ;; (at your option) any later version.
14 |
15 | ;; This program is distributed in the hope that it will be useful,
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | ;; GNU General Public License for more details.
19 |
20 | ;; You should have received a copy of the GNU General Public License
21 | ;; along with this program. If not, see .
22 |
23 | ;;; Commentary:
24 |
25 | ;; org-calctex integrates calctex with Org mode.
26 |
27 | ;;; Code:
28 |
29 | (require 'org)
30 | (require 'calctex)
31 | (require 'hydra)
32 | (require 'posframe)
33 | (require 'cdlatex)
34 |
35 | (defvar calctex--last-frag nil)
36 |
37 | (defvar org-calctex--equation-jump-mark nil)
38 |
39 | (defun calctex--render-just-exited-overlay ()
40 | (if (and (not (calctex-latex-fragment-at-point))
41 | calctex--last-overlay
42 | calctex--last-frag)
43 | (progn
44 | (calctex--render-overlay-at-frag calctex--last-frag calctex--last-overlay)
45 | (setq calctex--last-overlay nil
46 | calctex--last-frag nil))))
47 |
48 | (defun calctex--get-or-create-overlay-at-frag (frag)
49 | (let* ((beg (org-element-property :begin frag))
50 | (end (save-excursion
51 | (goto-char (org-element-property :end frag))
52 | (skip-chars-backward " \r\t\n")
53 | (point))))
54 | (calctex--get-or-create-overlay beg end)))
55 |
56 | (defun calctex--render-overlay-at-frag (frag ov)
57 | (let* ((tex (org-element-property :value frag))
58 | (margin (if (or (string-prefix-p "\\[" tex)
59 | (string-prefix-p "\begin" tex))
60 | 4
61 | 1)))
62 | (overlay-put ov 'modification-hooks '(calctex--modification-hook))
63 | (calctex--render-overlay-at tex ov margin)))
64 |
65 | (defun calctex-latex-fragment-at-point ()
66 | "Return the LaTeX fragment at point, or nil if none."
67 | (let ((ctx (org-element-context)))
68 | (if (or (eq 'latex-fragment (org-element-type ctx))
69 | (eq 'latex-environment (org-element-type ctx)))
70 | ctx
71 | nil)))
72 |
73 | (add-hook 'fill-nobreak-predicate #'calctex-latex-fragment-at-point)
74 |
75 | (defun calctex--modification-hook (ov after beg end &optional len)
76 | (condition-case nil
77 | (calctex--render-overlay-at-point)
78 | (error (progn
79 | (calctex--remove-overlay-at-point)))))
80 |
81 | (defun calctex--render-overlay-at-point ()
82 | (let ((frag (calctex-latex-fragment-at-point)))
83 | (if frag
84 | (let ((ov (calctex--get-or-create-overlay-at-frag frag)))
85 | (if ov
86 | (progn
87 | (calctex--render-overlay-at-frag frag ov)
88 | (setq calctex--last-overlay ov
89 | calctex--last-frag frag)
90 | )
91 | ()))
92 | ())))
93 |
94 | (defun org-calctex-overlay-at-point ()
95 | (let* ((overlays (overlays-at (point)))
96 | (overlays (seq-filter (lambda (ov)
97 | (eq (overlay-get ov 'calctex-overlay-type) 'calctex-overlay))
98 | overlays)))
99 | (car overlays)))
100 |
101 | ;;;###autoload
102 | (defun org-calctex-hide-overlay-at-point ()
103 | "Toggle display of the overlay at point."
104 | (interactive)
105 | (let* ((ov (org-calctex-overlay-at-point)))
106 | (if ov
107 | (delete-overlay ov)
108 | (calctex--render-overlay-at-point))))
109 |
110 | (defun calctex-move-to-end-of-frag ()
111 | (let ((ov (org-calctex-overlay-at-point)))
112 | (if ov (goto-char (overlay-end ov)))))
113 |
114 | (defun calctex--marker-within-frag (marker frag)
115 | (if marker
116 | (let* ((begin (org-element-property :begin frag))
117 | (pt (- marker begin)))
118 | pt)
119 | nil))
120 |
121 | ;; Activate all formulas for embedded mode
122 | (defun org-calctex--activate-all ()
123 | (interactive)
124 | ;; Straight out of org.el
125 | (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \t]*\\\\begin{[A-Za-z0-9*]+}")
126 | (cnt 0))
127 | (goto-char (point-min))
128 | (while (re-search-forward math-regexp (point-max) t)
129 | (let* ((context (org-element-context))
130 | (type (org-element-type context)))
131 | (when (memq type '(latex-environment latex-fragment))
132 | (calc-embedded nil))))))
133 |
134 | ;;; Movement
135 |
136 | (defun org-calctex-next-formula ()
137 | (interactive)
138 | (let* ((frag (calctex-latex-fragment-at-point))
139 | (math-regexp "\\$\\|\\\\[([]\\|^[ \t]*\\\\begin{[A-Za-z0-9*]+}")
140 | )
141 | (progn
142 | (if frag
143 | (progn
144 | (goto-char (org-element-property :end frag))
145 | (forward-char))
146 | ())
147 | (re-search-forward math-regexp (point-max) t)
148 | (let* ((frag (calctex-latex-fragment-at-point))
149 | (begin (org-element-property :begin frag)))
150 | (goto-char begin))
151 | (setq disable-point-adjustment t))))
152 |
153 | (defun org-calctex-prev-formula ()
154 | (interactive)
155 | (let* ((frag (calctex-latex-fragment-at-point))
156 | (math-regexp "\\$\\|\\\\[([]\\|^[ \t]*\\\\begin{[A-Za-z0-9*]+}"))
157 | (progn
158 | (if frag
159 | (progn
160 | (goto-char (org-element-property :begin frag))
161 | (backward-char))
162 | ())
163 | (re-search-backward math-regexp (point-min) t)
164 | (if (eq ?$ (char-after (point)))
165 | ;; Go backwards a character because frag-at-point doesn't work on the closing $
166 | (backward-char))
167 | (let* ((frag (calctex-latex-fragment-at-point))
168 | (begin (org-element-property :begin frag)))
169 | (goto-char begin))
170 | (setq disable-point-adjustment t))))
171 |
172 | ;;; Activate/Accept
173 |
174 | (defvar calctex--calc-posframe nil)
175 | (defun org-calctex-activate-posframe ()
176 | "Activate the *Calculator* buffer through a posframe
177 | and have it accept keyboard input."
178 | (interactive)
179 | (let* ((position (point))
180 | (poshandler #'posframe-poshandler-point-bottom-left-corner)
181 |
182 | (width 500)
183 | (height 500)
184 |
185 | (min-width 1)
186 | (min-height 1)
187 | (x-pixel-offset 0)
188 | (y-pixel-offset 0)
189 |
190 | (left-fringe 0)
191 | (right-fringe 0)
192 |
193 | (parent-window (selected-window))
194 |
195 | (position-info (posn-at-point position parent-window))
196 |
197 | (parent-window-top (window-pixel-top parent-window))
198 | (parent-window-left (window-pixel-left parent-window))
199 | (parent-window-width (window-pixel-width parent-window))
200 | (parent-window-height (window-pixel-height parent-window))
201 |
202 | (mode-line-height (window-mode-line-height))
203 | (minibuffer-height (window-pixel-height (minibuffer-window)))
204 |
205 | (header-line-height (window-header-line-height parent-window))
206 | (tab-line-height (if (functionp 'window-tab-line-height)
207 | (window-tab-line-height)
208 | 0))
209 |
210 | (parent-frame (window-frame parent-window))
211 | (parent-frame-width (frame-pixel-width parent-frame))
212 | (parent-frame-height (frame-pixel-height parent-frame))
213 |
214 | (font-width (default-font-width))
215 | (font-height (with-current-buffer (window-buffer parent-window)
216 | (posframe--get-font-height position)))
217 |
218 | (calc-buffer (get-buffer "*Calculator*"))
219 |
220 | (frame (if (and calctex--calc-posframe (frame-live-p calctex--calc-posframe))
221 | calctex--calc-posframe
222 | (make-frame
223 | `((minibuffer . t)
224 | (internal-border-width . 1)
225 | (parent-frame . ,parent-frame)
226 | (undecorated . nil)))))
227 |
228 | (frame-relative-pos (posframe-poshandler-point-bottom-left-corner
229 | `(;All poshandlers will get info from this plist.
230 | :position ,position
231 | :position-info ,position-info
232 | :poshandler ,poshandler
233 | :font-height ,font-height
234 | :font-width ,font-width
235 | :posframe ,frame
236 | :posframe-width ,width
237 | :posframe-height ,height
238 | :posframe-buffer ,calc-buffer
239 | :parent-frame ,parent-frame
240 | :parent-frame-width ,parent-frame-width
241 | :parent-frame-height ,parent-frame-height
242 | :parent-window ,parent-window
243 | :parent-window-top ,parent-window-top
244 | :parent-window-left ,parent-window-left
245 | :parent-window-width ,parent-window-width
246 | :parent-window-height ,parent-window-height
247 | :mode-line-height ,mode-line-height
248 | :minibuffer-height ,minibuffer-height
249 | :header-line-height ,header-line-height
250 | :tab-line-height ,tab-line-height
251 | :x-pixel-offset ,x-pixel-offset
252 | :y-pixel-offset ,y-pixel-offset))))
253 | (progn
254 | (set-frame-position frame (car frame-relative-pos) (cdr frame-relative-pos))
255 | (setq calctex--parent-frame (selected-frame))
256 | (select-frame frame)
257 | (set-face-background 'internal-border "black" frame)
258 | (delete-other-windows-internal)
259 | (set-window-buffer (selected-window) calc-buffer)
260 | (set-window-dedicated-p (selected-window) t)
261 | (setq calctex--calc-posframe frame)
262 | (make-frame-visible calctex--calc-posframe)
263 | )))
264 |
265 | (defun org-calctex-activate ()
266 | (interactive)
267 | (org-calctex-activate-posframe)
268 | )
269 |
270 | (defun org-calctex-accept-formula ()
271 | (interactive)
272 | (make-frame-invisible calctex--calc-posframe)
273 | (select-frame calctex--parent-frame)
274 | (if (equal evil-state 'visual)
275 | (let ((current-prefix-arg '(4)))
276 | (progn
277 | (call-interactively 'calc-copy-to-buffer)))
278 | (calc-copy-to-buffer nil))
279 | (evil-insert-state)
280 | )
281 |
282 | ;; Activate the formula at point with calc Embedded mode.
283 | (defun org-calctex-activate-formula ()
284 | "Activate the formula at point with calc Embedded mode,
285 | and opens the calc application to edit it..
286 |
287 | Saves point in the register `f'. The function `org-calctex-accept-formula'
288 | jumps back to register `f'."
289 | (interactive)
290 | (let* ((frag (calctex-latex-fragment-at-point)))
291 | (if frag
292 | (progn
293 | (goto-char (org-element-property :begin frag))
294 | (when (equal (char-after (point)) ?$) (forward-char))
295 | (calc-embedded nil)
296 | ;(calctex--render-overlay-at-point)
297 |
298 | (posframe-show "*Calculator*"
299 | :position (point)
300 | :internal-border-width 1
301 | :internal-border-color "black")
302 |
303 | (setq calctex--parent-frame (selected-frame))
304 | (let* ((frame (buffer-local-value 'posframe--frame (get-buffer "*Calculator*")))
305 | (window (frame-selected-window frame)))
306 | (progn
307 | (redirect-frame-focus calctex--parent-frame frame)
308 | (select-frame frame)
309 | ))
310 | )
311 | (message "no frag"))))
312 |
313 | (defun org-calctex-accept-formula-old ()
314 | "Accept the formula and jump to the end of it"
315 | (interactive)
316 | (calc-embedded t)
317 | (posframe-hide "*Calculator*")
318 | (let ((frag (calctex-latex-fragment-at-point)))
319 | (goto-char (org-element-property :end frag))))
320 |
321 | ;;; Insertion
322 |
323 | (defun calctex-append-inline-formula ()
324 | (interactive)
325 | (let* ((frag (calctex-latex-fragment-at-point)))
326 | (if frag
327 | (progn
328 | (goto-char (org-element-property :end frag))
329 | (save-excursion (insert " "))
330 | )))
331 | (let ((calc-embedded-open-new-formula "$")
332 | (calc-embedded-close-new-formula "$"))
333 | (progn
334 | (calc-embedded-new-formula)
335 | (bookmark-set "calctex-formula")
336 | (calctex--render-overlay-at-point)
337 | (calc))))
338 |
339 | (defun calctex-insert-display-formula ()
340 | (interactive)
341 | (evil-insert-newline-below)
342 | (let ((calc-embedded-open-new-formula "\\begin{align*} ")
343 | (calc-embedded-close-new-formula "\\end{align*}"))
344 | (progn
345 | (calc-embedded-new-formula)
346 | (bookmark-set "calctex-formula")
347 | (calctex--render-overlay-at-point)
348 | (calc))))
349 |
350 | ;;; Post-insert hooks
351 |
352 | (defun calctex-mode-hook-hook ()
353 | (add-hook 'post-self-insert-hook #'org-calctex-complete-and-activate-formula nil t))
354 | (add-hook 'calctex-mode-hook #'calctex-mode-hook-hook)
355 |
356 | (defun org-calctex-complete-and-activate-formula ()
357 | (cond ((equal (char-before) 36) (org-calctex--complete-inline-formula))
358 | ((equal (char-before) 91) (org-calctex--maybe-complete-and-activate-display-formula))))
359 |
360 | (defun org-calctex--complete-inline-formula ()
361 | (save-excursion
362 | (backward-char)
363 | (when (calctex-latex-fragment-at-point)
364 | (org-calctex-hide-overlay-at-point))))
365 |
366 | (defun org-calctex--maybe-complete-and-activate-display-formula ()
367 | ; Check if we just typed "\["
368 | (if (save-excursion
369 | (backward-char)
370 | (equal (char-before) 92))
371 | (progn
372 | ; Ensure the equation is on its own line
373 | (save-excursion
374 | (backward-char 2)
375 | (unless (equal (char-before) 10)
376 | (newline)))
377 | (save-excursion
378 | (move-end-of-line nil)
379 | (insert "\\]")
380 | (org-calctex-hide-overlay-at-point)
381 | (org-calctex-activate-formula))
382 | )))
383 |
384 | (defhydra cdlatex-environment-hydra (:color red)
385 | ("a" (cdlatex-environment "align*") "align*" :color blue)
386 | ("A" (cdlatex-environment "align") "align" :color blue)
387 | ("e" (cdlatex-environment "equation*") "equation*" :color blue)
388 | ("E" (cdlatex-environment "equation") "equation" :color blue)
389 | ("c" (cdlatex-environment "cases") "cases" :color blue)
390 | ("p" (cdlatex-environment "pmatrix") "pmatrix" :color blue))
391 |
392 | ;;;###autoload (autoload 'calctex-hydra/body "org-calctex" nil t)
393 | (defhydra calctex-hydra (:color red)
394 | ("h" org-calctex-hide-overlay-at-point "show/hide overlays")
395 | ("n" org-calctex-next-formula "next")
396 | ("p" org-calctex-prev-formula "prev")
397 | ("r" org-calctex-activate "replace" :color blue)
398 | ("e" cdlatex-environment-hydra/body "Insert equation environment" :color blue)
399 | ("q" nil "quit" :color blue))
400 |
401 | (provide 'org-calctex)
402 |
403 | ;;; org-calctex.el ends here
404 |
--------------------------------------------------------------------------------
/tangle_install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | emacs --batch -l org README.org -f org-babel-tangle
4 |
--------------------------------------------------------------------------------
/test/calctex-contrib-test.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright (C) 2019 John B Coughlin
4 |
5 | ;; This program is free software: you can redistribute it and/or modify
6 | ;; it under the terms of the GNU General Public License as published by
7 | ;; the Free Software Foundation, either version 3 of the License, or
8 | ;; (at your option) any later version.
9 |
10 | ;; This program is distributed in the hope that it will be useful,
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | ;; GNU General Public License for more details.
14 |
15 | ;; You should have received a copy of the GNU General Public License
16 | ;; along with this program. If not, see .
17 |
18 | (require 'calc)
19 | (require 'calccomp)
20 | (require 'calctex-contrib)
21 | (require 'ert)
22 |
23 | (defun with-calc-test-harness (body)
24 | (calc)
25 | (calc-reset 0)
26 | (calc-no-simplify-mode t)
27 | (calc-line-breaking nil)
28 | (calc-algebraic-mode 0)
29 | (calc-symbolic-mode t)
30 | (calc-latex-language nil)
31 | (setq calctex-contrib-context-decls (list))
32 | (calctex-contrib-refresh)
33 | (with-current-buffer "*Calculator*" (funcall body)))
34 |
35 | (defun with-calc-test-harness-normal-language (body)
36 | (calc)
37 | (calc-reset 0)
38 | (calc-line-breaking nil)
39 | (calc-no-simplify-mode t)
40 | (calc-normal-language)
41 | (with-current-buffer "*Calculator*" (funcall body)))
42 |
43 | (defun calc-stack-line (n)
44 | (with-current-buffer "*Calculator*"
45 | (goto-char (point-min))
46 | (forward-line n)
47 | (let* ((line-start (if calc-line-numbering
48 | (+ (line-beginning-position) 4)
49 | (line-beginning-position)))
50 | (line-end (line-end-position))
51 | (line-contents (buffer-substring line-start line-end)))
52 | line-contents)))
53 |
54 | (ert-deftest test-displays-vector-variable ()
55 | (with-calc-test-harness
56 | (lambda ()
57 | (setq calctex-contrib-context-decls
58 | (list "[a, vector]"))
59 | (calctex-contrib-refresh)
60 | (calc-eval "a" 'push)
61 | (should (equal (calc-stack-line 1) "\\vec{a}")))))
62 |
63 | (ert-deftest test-displays-vector-variable-normal ()
64 | (with-calc-test-harness-normal-language
65 | (lambda ()
66 | (setq calctex-contrib-context-decls
67 | (list "[a, vector]"))
68 | (calctex-contrib-refresh)
69 | (calc-eval "a" 'push)
70 | (should (equal (calc-stack-line 1) "vec(a)")))))
71 |
72 | (ert-deftest test-displays-matrix-no-particular-way ()
73 | (with-calc-test-harness
74 | (lambda ()
75 | (setq calctex-contrib-context-decls
76 | (list "[A, matrix]"))
77 | (calctex-contrib-refresh)
78 | (calc-eval "A" 'push)
79 | (should (equal (calc-stack-line 1) "A")))))
80 |
81 | (ert-deftest test-displays-total-derivative-of-var ()
82 | (with-calc-test-harness
83 | (lambda ()
84 | (calc-eval "f" 'push)
85 | (calc-eval "Hadx\r" 'macro)
86 | (should (equal (calc-stack-line 1) "\\frac{\\mathrm{d}f}{\\mathrm{d}x}")))))
87 |
88 | (ert-deftest test-displays-partial-derivative-of-var ()
89 | (with-calc-test-harness
90 | (lambda ()
91 | (calc-eval "g" 'push)
92 | (calc-eval "adx\r" 'macro)
93 | (should (equal (calc-stack-line 1) "\\frac{\\partial g}{\\partial x}")))))
94 |
95 | (ert-deftest test-derivative-of-multieq ()
96 | (with-calc-test-harness
97 | (lambda ()
98 | (calctex-contrib-refresh)
99 | (calc-eval "eq(a, deriv(b, x), c)" 'push)
100 | (should (equal (calc-stack-line 1) "a = \\frac{\\partial b}{\\partial x} = c")))))
101 |
102 | (ert-deftest test-derivative-of-vector ()
103 | (with-calc-test-harness
104 | (lambda ()
105 | (setq calctex-contrib-context-decls
106 | (list "[a, vector]"))
107 | (calctex-contrib-refresh)
108 | (calc-eval "a" 'push)
109 | (calc-eval "adx\r" 'macro)
110 | (should (equal (calc-stack-line 1) "\\frac{\\partial \\vec{a}}{\\partial x}")))))
111 |
112 | (ert-deftest test-cos-power ()
113 | (with-calc-test-harness
114 | (lambda ()
115 | (calc-eval "cos(x)^n" 'push)
116 | (should (equal (calc-stack-line 1) "\\cos^{n}{x}"))
117 | )))
118 |
119 | (ert-deftest test-sin-power ()
120 | (with-calc-test-harness
121 | (lambda ()
122 | (calc-eval "sin(x)^n" 'push)
123 | (should (equal (calc-stack-line 1) "\\sin^{n}{x}"))
124 | )))
125 |
126 | (ert-deftest test-multieq ()
127 | (with-calc-test-harness
128 | (lambda ()
129 | (calc-eval "eq(a, b, c)" 'push)
130 | (should (equal (calc-stack-line 1) "a = b = c")))))
131 |
132 | (ert-deftest test-integrals-not-simplified ()
133 | (with-calc-test-harness
134 | (lambda ()
135 | (calc-eval "((cos(g) exp(g)) exp(sin(sqrt(f + g^2)))) (g^3 - e^g)" 'push)
136 | (calc-eval "aig" 'macro)
137 | (let ((messages (with-current-buffer "*Messages*"
138 | (re-search-backward "Working... Integrating" nil t))))
139 | (should (equal messages nil))))))
140 |
--------------------------------------------------------------------------------
/test/calctex-test.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright (C) 2019 John B Coughlin
4 |
5 | ;; This program is free software: you can redistribute it and/or modify
6 | ;; it under the terms of the GNU General Public License as published by
7 | ;; the Free Software Foundation, either version 3 of the License, or
8 | ;; (at your option) any later version.
9 |
10 | ;; This program is distributed in the hope that it will be useful,
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | ;; GNU General Public License for more details.
14 |
15 | ;; You should have received a copy of the GNU General Public License
16 | ;; along with this program. If not, see .
17 |
18 | (require 'calctex)
19 | (require 'ert)
20 |
21 | (defun with-calc-test-harness (body)
22 | (set-face-attribute 'default nil :foreground "black" :background "white")
23 | (calc)
24 | (calc-reset 0)
25 | (with-current-buffer "*Calculator*"
26 | (let* ((tempdir-name (make-temp-name temporary-file-directory))
27 | (calctex-latex-image-directory tempdir-name))
28 | (make-directory calctex-latex-image-directory)
29 | (funcall body))))
30 |
31 | (defun nth-overlay (n)
32 | (let* ((ovs (overlays-in (point-min) (point-max)))
33 | (ov (nth n ovs)))
34 | (if ov
35 | ov
36 | (message "
37 | ==========Render error output:==========
38 | %s
39 |
40 | ========================================
41 | " (with-current-buffer "*CalcTeX-DVIPNG*"
42 | (buffer-string))))))
43 |
44 | (defun overlay-display-property (ov prop)
45 | (let* ((disp (overlay-get ov 'display)))
46 | (plist-get (cdr disp) prop)))
47 |
48 | (defun assert-no-overlays ()
49 | (let* ((ovs (overlays-in (point-min) (point-max))))
50 | (should (= 0 (length ovs)))))
51 |
52 | (defun assert-nth-overlay-image-equals (n reference-image)
53 | (assert-overlay-image-equals
54 | (nth-overlay n)
55 | reference-image))
56 |
57 | (defun assert-renders-tex-to-image (tex reference-image)
58 | (let* ((img (funcall calctex-render-process tex))
59 | (img-file (plist-get img 'file))
60 | (img-type (plist-get img 'type)))
61 | (assert-image-equals img-file reference-image)))
62 |
63 | (ert-deftest test-displays-image-correctly ()
64 | (with-calc-test-harness
65 | (lambda ()
66 | (calctex-mode 1)
67 | (execute-kbd-macro (kbd "' a "))
68 | (execute-kbd-macro (kbd "2 *"))
69 | (let ((ov (nth-overlay 0)))
70 | (assert-overlay-image-equals ov "2a.png")))))
71 |
72 | (ert-deftest test-changes-image-overlay-live ()
73 | (with-calc-test-harness
74 | (lambda ()
75 | (calctex-mode 1)
76 | (execute-kbd-macro (kbd "' a "))
77 | (execute-kbd-macro (kbd "2 *"))
78 | (assert-nth-overlay-image-equals 0 "2a.png")
79 | (execute-kbd-macro (kbd "2 *"))
80 | (assert-nth-overlay-image-equals 0 "4a.png"))))
81 |
82 | (ert-deftest test-turning-off-calctex-hides-overlays ()
83 | (with-calc-test-harness
84 | (lambda ()
85 | (calctex-mode 1)
86 | (execute-kbd-macro (kbd "' a "))
87 | (execute-kbd-macro (kbd "2 *"))
88 | (calctex-mode -1)
89 | (assert-no-overlays))))
90 |
91 | (ert-deftest test-switching-language-mode-hides-overlays ()
92 | (with-calc-test-harness
93 | (lambda ()
94 | (calctex-mode 1)
95 | (execute-kbd-macro (kbd "' a "))
96 | (execute-kbd-macro (kbd "2 *"))
97 | (execute-kbd-macro (kbd "d N"))
98 | (assert-no-overlays))))
99 |
100 | (ert-deftest test-multiple-overlays ()
101 | (with-calc-test-harness
102 | (lambda ()
103 | (calctex-mode 1)
104 | (execute-kbd-macro (kbd "' a "))
105 | (execute-kbd-macro (kbd "2 *"))
106 | (execute-kbd-macro (kbd ""))
107 | (execute-kbd-macro (kbd "2 *"))
108 | (assert-nth-overlay-image-equals 0 "2a.png")
109 | (assert-nth-overlay-image-equals 1 "4a.png")
110 | )))
111 |
112 | (ert-deftest test-imagemagick-disabled ()
113 | (with-calc-test-harness
114 | (lambda ()
115 | (let ((calctex-imagemagick-enabled-p nil))
116 | (calctex-mode 1)
117 | (execute-kbd-macro (kbd "' a "))
118 | (execute-kbd-macro (kbd "2 *"))
119 | (let ((ov (nth-overlay 0)))
120 | (assert-overlay-image-equals ov "2a_lowres.png")
121 | (should (equal (overlay-display-property ov :type) 'png)))
122 | ))))
123 |
124 | (ert-deftest test-imagemagick-enabled ()
125 | (with-calc-test-harness
126 | (lambda ()
127 | (let ((calctex-imagemagick-enabled-p t))
128 | (calctex-mode 1)
129 | (execute-kbd-macro (kbd "' a "))
130 | (execute-kbd-macro (kbd "2 *"))
131 | (let ((ov (nth-overlay 0)))
132 | (assert-overlay-image-equals ov "2a.png")
133 | (should (equal (overlay-display-property ov :type) 'imagemagick))
134 | (should (equal (overlay-display-property ov :format) 'png))
135 | (should (equal (overlay-display-property ov :scale) (/ calctex-imagemagick-png-scaling calctex-base-imagemagick-png-scaling)))))
136 | )))
137 |
138 | (ert-deftest creates-parents-of-image-cache ()
139 | (progn
140 | (with-calc-test-harness
141 | (lambda ()
142 | (let ((calctex-latex-image-directory "./calctex-image-cache"))
143 | (progn
144 | (calctex-mode 1)
145 | (execute-kbd-macro (kbd "' a "))
146 | (execute-kbd-macro (kbd "2 *"))
147 | (assert-nth-overlay-image-equals 0 "2a.png")))))))
148 |
149 | (ert-deftest renders-si ()
150 | (progn
151 | (set-face-attribute 'default nil :foreground "black" :background "white")
152 | (assert-renders-tex-to-image
153 | "\\[ \\boxed{\\eta = \\frac{\\SI{6.27e8}{\\joule}}{\\SI{7.96e9}{\\joule}} = 0.0787} \\]"
154 | "joules.png")))
155 |
156 | (provide 'calctex-test)
157 |
--------------------------------------------------------------------------------
/test/org-calctex-test.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright (C) 2019 John B Coughlin
4 |
5 | ;; This program is free software: you can redistribute it and/or modify
6 | ;; it under the terms of the GNU General Public License as published by
7 | ;; the Free Software Foundation, either version 3 of the License, or
8 | ;; (at your option) any later version.
9 |
10 | ;; This program is distributed in the hope that it will be useful,
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | ;; GNU General Public License for more details.
14 |
15 | ;; You should have received a copy of the GNU General Public License
16 | ;; along with this program. If not, see .
17 |
18 | (require 'org-calctex)
19 | (require 'ert)
20 |
21 | (defun with-org-calctex-test-harness (body &optional file)
22 | (message "%s" (resource-file "test.org"))
23 | (find-file (if file file (resource-file "test.org")))
24 | (revert-buffer nil t)
25 | (message "Removing overlays")
26 | (remove-overlays)
27 | (set-face-attribute 'default nil :foreground "black" :background "white")
28 | (calctex-mode 1)
29 | (goto-char 1)
30 | (funcall body))
31 |
32 | (ert-deftest test-next-formula ()
33 | (with-org-calctex-test-harness
34 | (lambda ()
35 | (org-calctex-next-formula)
36 | (should (equal (point) 28))
37 | (org-calctex-next-formula)
38 | (should (equal (point) 87)))))
39 |
40 | (ert-deftest test-next-formula-point-within-formula ()
41 | (with-org-calctex-test-harness
42 | (lambda ()
43 | (goto-char 30)
44 | (org-calctex-next-formula)
45 | (should (equal (point) 87)))))
46 |
47 | (ert-deftest test-previous-formula ()
48 | (message "FOO!!" (buffer-substring (point-min) (point-max)))
49 | (with-org-calctex-test-harness
50 | (lambda ()
51 | (message "%s" (buffer-substring (point-min) (point-max)))
52 | (goto-char 133)
53 | (org-calctex-prev-formula)
54 | (should (equal (point) 87))
55 | (org-calctex-prev-formula)
56 | (should (equal (point) 28)))))
57 |
58 | (ert-deftest test-previous-formula-point-within-formula ()
59 | (with-org-calctex-test-harness
60 | (lambda ()
61 | (goto-char 75)
62 | (org-calctex-prev-formula)
63 | (should (equal (point) 28)))))
64 |
65 | ;; (ert-deftest test-activate-and-accept ()
66 | ;; (with-org-calctex-test-harness
67 | ;; (lambda ()
68 | ;; (org-calctex-next-formula)
69 | ;; (org-calctex-activate-formula)
70 | ;; (execute-kbd-macro (kbd "' f ( x ) "))
71 | ;; (execute-kbd-macro (kbd "' x ^ 2 "))
72 | ;; (execute-kbd-macro (kbd "a = "))
73 | ;; (org-calctex-accept-formula))))
74 |
75 | (ert-deftest test-accept-jumps-to-end-of-formula ()
76 | (with-org-calctex-test-harness
77 | (lambda ()
78 | (org-calctex-next-formula)
79 | (let ((formula-start (point)))
80 | (org-calctex-activate-formula)
81 | (execute-kbd-macro (kbd "' f ( x ) "))
82 | (org-calctex-accept-formula)
83 | (progn
84 | (should (equal (point) (+ formula-start 4 4)))
85 | (should (equal (buffer-substring formula-start (point)) "\\[f(x)\\]")))))))
86 |
87 | (ert-deftest test-jump-to-align ()
88 | (with-org-calctex-test-harness
89 | (lambda ()
90 | (org-calctex-next-formula)
91 | (should (equal (point) 13)))
92 | (resource-file "alignstar.org")))
93 |
94 | (ert-deftest test-activate-align ()
95 | (with-org-calctex-test-harness
96 | (lambda ()
97 | (org-calctex-next-formula)
98 | (let ((formula-start (point)))
99 | (org-calctex-activate-formula)
100 | (execute-kbd-macro (kbd "' j "))
101 | (execute-kbd-macro (kbd "+"))
102 | (org-calctex-accept-formula)
103 | ))
104 | (resource-file "alignstar.org")))
105 |
106 | (ert-deftest test-show-hide-overlay ()
107 | (with-org-calctex-test-harness
108 | (lambda ()
109 | (org-calctex-next-formula)
110 | (redisplay)
111 | (message "%s" (current-buffer))
112 | (org-calctex-hide-overlay-at-point)
113 | (message "%s" (current-buffer))
114 | (message "%s" (point))
115 | (message "%s" (org-calctex-overlay-at-point))
116 | (redisplay)
117 | (sleep-for 3)
118 | (assert-overlay-image-equals (org-calctex-overlay-at-point) "pythag.png")
119 | ; (org-calctex-hide-overlay-at-point)
120 | ;(should (equal nil (org-calctex-overlay-at-point)))
121 | )))
122 |
123 |
124 | (provide 'org-calctex-test)
125 |
--------------------------------------------------------------------------------
/test/resources/2a.dvi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/2a.dvi
--------------------------------------------------------------------------------
/test/resources/2a.log:
--------------------------------------------------------------------------------
1 | This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex 2019.5.19) 3 OCT 2019 08:01
2 | entering extended mode
3 | restricted \write18 enabled.
4 | %&-line parsing enabled.
5 | **resources/2a.tex
6 | (./resources/2a.tex
7 | LaTeX2e <2018-12-01>
8 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/article.cls
9 | Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
10 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/size10.clo
11 | File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
12 | )
13 | \c@part=\count80
14 | \c@section=\count81
15 | \c@subsection=\count82
16 | \c@subsubsection=\count83
17 | \c@paragraph=\count84
18 | \c@subparagraph=\count85
19 | \c@figure=\count86
20 | \c@table=\count87
21 | \abovecaptionskip=\skip41
22 | \belowcaptionskip=\skip42
23 | \bibindent=\dimen102
24 | )
25 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/color.sty
26 | Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
27 |
28 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
29 | File: color.cfg 2016/01/02 v1.6 sample color configuration
30 | )
31 | Package color Info: Driver file: dvips.def on input line 147.
32 |
33 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-def/dvips.def
34 | File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
35 | )
36 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/dvipsnam.def
37 | File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
38 | ))
39 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xcolor/xcolor.sty
40 | Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
41 |
42 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
43 | File: color.cfg 2016/01/02 v1.6 sample color configuration
44 | )
45 | Package xcolor Info: Driver file: dvips.def on input line 225.
46 | LaTeX Info: Redefining \color on input line 709.
47 | Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
48 | Package xcolor Info: Model `RGB' extended on input line 1364.
49 | Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
50 | Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
51 | Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
52 | Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
53 | Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
54 | Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
55 | )
56 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/soul/soul.sty
57 | Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
58 | \SOUL@word=\toks14
59 | \SOUL@lasttoken=\toks15
60 | \SOUL@cmds=\toks16
61 | \SOUL@buffer=\toks17
62 | \SOUL@token=\toks18
63 | \SOUL@spaceskip=\skip43
64 | \SOUL@ttwidth=\dimen103
65 | \SOUL@uldp=\dimen104
66 | \SOUL@ulht=\dimen105
67 | )
68 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjustbox.sty
69 | Package: adjustbox 2019/01/04 v1.2 Adjusting TeX boxes (trim, clip, ...)
70 |
71 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xkeyval/xkeyval.sty
72 | Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
73 |
74 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkeyval.tex
75 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkvutils.tex
76 | \XKV@toks=\toks19
77 | \XKV@tempa@toks=\toks20
78 |
79 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/keyval.tex))
80 | \XKV@depth=\count88
81 | File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
82 | ))
83 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjcalc.sty
84 | Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
85 | -ends (calc, etex, pgfmath)
86 | )
87 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/trimclip.sty
88 | Package: trimclip 2018/04/08 v1.1 Trim and clip general TeX material
89 |
90 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphicx.sty
91 | Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
92 |
93 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphics.sty
94 | Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
95 |
96 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/trig.sty
97 | Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
98 | )
99 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
100 | File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
101 | )
102 | Package graphics Info: Driver file: dvips.def on input line 99.
103 | )
104 | \Gin@req@height=\dimen106
105 | \Gin@req@width=\dimen107
106 | ) (/usr/local/texlive/2019basic/texmf-dist/tex/latex/collectbox/collectbox.sty
107 | Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
108 | \collectedbox=\box27
109 | )
110 | \tc@llx=\dimen108
111 | \tc@lly=\dimen109
112 | \tc@urx=\dimen110
113 | \tc@ury=\dimen111
114 | Package trimclip Info: Using driver 'tc-dvips.def'.
115 |
116 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/tc-dvips.def
117 | File: tc-dvips.def 2019/01/04 v2.2 Clipping driver for dvips
118 | ))
119 | \adjbox@Width=\dimen112
120 | \adjbox@Height=\dimen113
121 | \adjbox@Depth=\dimen114
122 | \adjbox@Totalheight=\dimen115
123 | \adjbox@pwidth=\dimen116
124 | \adjbox@pheight=\dimen117
125 | \adjbox@pdepth=\dimen118
126 | \adjbox@ptotalheight=\dimen119
127 | )
128 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
129 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3.sty
130 | Package: expl3 2019-04-06 L3 programming layer (loader)
131 |
132 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3-code.tex
133 | Package: expl3 2019-04-06 L3 programming layer (code)
134 | \c_max_int=\count89
135 | \l_tmpa_int=\count90
136 | \l_tmpb_int=\count91
137 | \g_tmpa_int=\count92
138 | \g_tmpb_int=\count93
139 | \g__kernel_prg_map_int=\count94
140 | \c__ior_term_ior=\count95
141 | \c_log_iow=\count96
142 | \l_iow_line_count_int=\count97
143 | \l__iow_line_target_int=\count98
144 | \l__iow_one_indent_int=\count99
145 | \l__iow_indent_int=\count100
146 | \c_zero_dim=\dimen120
147 | \c_max_dim=\dimen121
148 | \l_tmpa_dim=\dimen122
149 | \l_tmpb_dim=\dimen123
150 | \g_tmpa_dim=\dimen124
151 | \g_tmpb_dim=\dimen125
152 | \c_zero_skip=\skip44
153 | \c_max_skip=\skip45
154 | \l_tmpa_skip=\skip46
155 | \l_tmpb_skip=\skip47
156 | \g_tmpa_skip=\skip48
157 | \g_tmpb_skip=\skip49
158 | \c_zero_muskip=\muskip10
159 | \c_max_muskip=\muskip11
160 | \l_tmpa_muskip=\muskip12
161 | \l_tmpb_muskip=\muskip13
162 | \g_tmpa_muskip=\muskip14
163 | \g_tmpb_muskip=\muskip15
164 | \l_keys_choice_int=\count101
165 | \l__intarray_loop_int=\count102
166 | \c__intarray_sp_dim=\dimen126
167 | \g__intarray_font_int=\count103
168 | \c__fp_leading_shift_int=\count104
169 | \c__fp_middle_shift_int=\count105
170 | \c__fp_trailing_shift_int=\count106
171 | \c__fp_big_leading_shift_int=\count107
172 | \c__fp_big_middle_shift_int=\count108
173 | \c__fp_big_trailing_shift_int=\count109
174 | \c__fp_Bigg_leading_shift_int=\count110
175 | \c__fp_Bigg_middle_shift_int=\count111
176 | \c__fp_Bigg_trailing_shift_int=\count112
177 | \c__kernel_randint_max_int=\count113
178 | \g__fp_array_int=\count114
179 | \l__fp_array_loop_int=\count115
180 | \l__sort_length_int=\count116
181 | \l__sort_min_int=\count117
182 | \l__sort_top_int=\count118
183 | \l__sort_max_int=\count119
184 | \l__sort_true_max_int=\count120
185 | \l__sort_block_int=\count121
186 | \l__sort_begin_int=\count122
187 | \l__sort_end_int=\count123
188 | \l__sort_A_int=\count124
189 | \l__sort_B_int=\count125
190 | \l__sort_C_int=\count126
191 | \l__tl_analysis_normal_int=\count127
192 | \l__tl_analysis_index_int=\count128
193 | \l__tl_analysis_nesting_int=\count129
194 | \l__tl_analysis_type_int=\count130
195 | \l__regex_internal_a_int=\count131
196 | \l__regex_internal_b_int=\count132
197 | \l__regex_internal_c_int=\count133
198 | \l__regex_balance_int=\count134
199 | \l__regex_group_level_int=\count135
200 | \l__regex_mode_int=\count136
201 | \c__regex_cs_in_class_mode_int=\count137
202 | \c__regex_cs_mode_int=\count138
203 | \l__regex_catcodes_int=\count139
204 | \l__regex_default_catcodes_int=\count140
205 | \c__regex_catcode_D_int=\count141
206 | \c__regex_catcode_S_int=\count142
207 | \c__regex_catcode_L_int=\count143
208 | \c__regex_catcode_O_int=\count144
209 | \c__regex_catcode_A_int=\count145
210 | \c__regex_all_catcodes_int=\count146
211 | \l__regex_show_lines_int=\count147
212 | \l__regex_min_state_int=\count148
213 | \l__regex_max_state_int=\count149
214 | \l__regex_left_state_int=\count150
215 | \l__regex_right_state_int=\count151
216 | \l__regex_capturing_group_int=\count152
217 | \l__regex_min_pos_int=\count153
218 | \l__regex_max_pos_int=\count154
219 | \l__regex_curr_pos_int=\count155
220 | \l__regex_start_pos_int=\count156
221 | \l__regex_success_pos_int=\count157
222 | \l__regex_curr_char_int=\count158
223 | \l__regex_curr_catcode_int=\count159
224 | \l__regex_last_char_int=\count160
225 | \l__regex_case_changed_char_int=\count161
226 | \l__regex_curr_state_int=\count162
227 | \l__regex_step_int=\count163
228 | \l__regex_min_active_int=\count164
229 | \l__regex_max_active_int=\count165
230 | \l__regex_replacement_csnames_int=\count166
231 | \l__regex_match_count_int=\count167
232 | \l__regex_min_submatch_int=\count168
233 | \l__regex_submatch_int=\count169
234 | \l__regex_zeroth_submatch_int=\count170
235 | \g__regex_trace_regex_int=\count171
236 | \c_empty_box=\box28
237 | \l_tmpa_box=\box29
238 | \l_tmpb_box=\box30
239 | \g_tmpa_box=\box31
240 | \g_tmpb_box=\box32
241 | \l__box_top_dim=\dimen127
242 | \l__box_bottom_dim=\dimen128
243 | \l__box_left_dim=\dimen129
244 | \l__box_right_dim=\dimen130
245 | \l__box_top_new_dim=\dimen131
246 | \l__box_bottom_new_dim=\dimen132
247 | \l__box_left_new_dim=\dimen133
248 | \l__box_right_new_dim=\dimen134
249 | \l__box_internal_box=\box33
250 | \l__coffin_internal_box=\box34
251 | \l__coffin_internal_dim=\dimen135
252 | \l__coffin_offset_x_dim=\dimen136
253 | \l__coffin_offset_y_dim=\dimen137
254 | \l__coffin_x_dim=\dimen138
255 | \l__coffin_y_dim=\dimen139
256 | \l__coffin_x_prime_dim=\dimen140
257 | \l__coffin_y_prime_dim=\dimen141
258 | \c_empty_coffin=\box35
259 | \l__coffin_aligned_coffin=\box36
260 | \l__coffin_aligned_internal_coffin=\box37
261 | \l_tmpa_coffin=\box38
262 | \l_tmpb_coffin=\box39
263 | \g_tmpa_coffin=\box40
264 | \g_tmpb_coffin=\box41
265 | \l__coffin_bounding_shift_dim=\dimen142
266 | \l__coffin_left_corner_dim=\dimen143
267 | \l__coffin_right_corner_dim=\dimen144
268 | \l__coffin_bottom_corner_dim=\dimen145
269 | \l__coffin_top_corner_dim=\dimen146
270 | \l__coffin_scaled_total_height_dim=\dimen147
271 | \l__coffin_scaled_width_dim=\dimen148
272 | \c__coffin_empty_coffin=\box42
273 | \l__coffin_display_coffin=\box43
274 | \l__coffin_display_coord_coffin=\box44
275 | \l__coffin_display_pole_coffin=\box45
276 | \l__coffin_display_offset_dim=\dimen149
277 | \l__coffin_display_x_dim=\dimen150
278 | \l__coffin_display_y_dim=\dimen151
279 | \g__file_internal_ior=\read1
280 | \l__seq_internal_a_int=\count172
281 | \l__seq_internal_b_int=\count173
282 | \c__deprecation_minus_one=\count174
283 | )
284 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/l3dvips.def
285 | File: l3dvips.def 2019-04-06 v L3 Experimental driver: dvips
286 | \g__driver_pdf_object_int=\count175
287 | ))
288 | Package: xparse 2019-03-05 L3 Experimental document command parser
289 | \l__xparse_current_arg_int=\count176
290 | \g__xparse_grabber_int=\count177
291 | \l__xparse_m_args_int=\count178
292 | \l__xparse_v_nesting_int=\count179
293 | )
294 | (resources/2a.aux)
295 | \openout1 = `2a.aux'.
296 |
297 | LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 55.
298 | LaTeX Font Info: ... okay on input line 55.
299 | LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 55.
300 | LaTeX Font Info: ... okay on input line 55.
301 | LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 55.
302 | LaTeX Font Info: ... okay on input line 55.
303 | LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 55.
304 | LaTeX Font Info: ... okay on input line 55.
305 | LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 55.
306 | LaTeX Font Info: ... okay on input line 55.
307 | LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 55.
308 | LaTeX Font Info: ... okay on input line 55.
309 | LaTeX Font Info: External font `cmex10' loaded for size
310 | (Font) <7> on input line 60.
311 | LaTeX Font Info: External font `cmex10' loaded for size
312 | (Font) <5> on input line 60.
313 | [1
314 |
315 | ] (resources/2a.aux) )
316 | Here is how much of TeX's memory you used:
317 | 11743 strings out of 494061
318 | 220360 string characters out of 6163061
319 | 243554 words of memory out of 5000000
320 | 15448 multiletter control sequences out of 15000+600000
321 | 532651 words of font info for 25 fonts, out of 8000000 for 9000
322 | 319 hyphenation exceptions out of 8191
323 | 40i,5n,63p,265b,317s stack positions out of 5000i,500n,10000p,200000b,80000s
324 |
325 | Output written on resources/2a.dvi (1 page, 460 bytes).
326 |
--------------------------------------------------------------------------------
/test/resources/2a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/2a.png
--------------------------------------------------------------------------------
/test/resources/2a.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 |
17 | \documentclass{article}
18 | \usepackage[usenames]{color}
19 | \pagestyle{empty} % do not remove
20 | % The settings below are copied from fullpage.sty
21 | \setlength{\textwidth}{\paperwidth}
22 | \addtolength{\textwidth}{-3cm}
23 | \setlength{\oddsidemargin}{1.5cm}
24 | \addtolength{\oddsidemargin}{-2.54cm}
25 | \setlength{\evensidemargin}{\oddsidemargin}
26 | \setlength{\textheight}{\paperheight}
27 | \addtolength{\textheight}{-\headheight}
28 | \addtolength{\textheight}{-\headsep}
29 | \addtolength{\textheight}{-\footskip}
30 | \addtolength{\textheight}{-3cm}
31 | \setlength{\topmargin}{1.5cm}
32 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
33 | \usepackage{xcolor}
34 | %\setlength{\fboxsep}{0pt}
35 | \usepackage{soul}
36 | \usepackage{adjustbox}
37 |
38 | \usepackage{xparse}
39 |
40 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
41 | \begingroup\colorlet{currcolor}{.}%
42 | \IfValueTF{#1}
43 | {\textcolor[#1]{#2}}
44 | {\textcolor{#2}}
45 | {%
46 | #3% the nucleus
47 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
48 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
49 | }%
50 | \endgroup
51 | }
52 |
53 | \newcommand{\cmt}[1]{\ignorespaces}
54 |
55 | \begin{document}
56 | \definecolor{fg}{rgb}{0 0 0}
57 | \definecolor{bg}{rgb}{1 1 1}
58 | \pagecolor{bg}
59 | {\color{fg}
60 | \[ \cmt{2 a} 2 a \]
61 | }
62 | \end{document}
--------------------------------------------------------------------------------
/test/resources/2a_lowres.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/2a_lowres.png
--------------------------------------------------------------------------------
/test/resources/4a.log:
--------------------------------------------------------------------------------
1 | This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex 2019.5.19) 3 OCT 2019 08:03
2 | entering extended mode
3 | restricted \write18 enabled.
4 | %&-line parsing enabled.
5 | **resources/4a.tex
6 | (./resources/4a.tex
7 | LaTeX2e <2018-12-01>
8 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/article.cls
9 | Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
10 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/size10.clo
11 | File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
12 | )
13 | \c@part=\count80
14 | \c@section=\count81
15 | \c@subsection=\count82
16 | \c@subsubsection=\count83
17 | \c@paragraph=\count84
18 | \c@subparagraph=\count85
19 | \c@figure=\count86
20 | \c@table=\count87
21 | \abovecaptionskip=\skip41
22 | \belowcaptionskip=\skip42
23 | \bibindent=\dimen102
24 | )
25 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/color.sty
26 | Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
27 |
28 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
29 | File: color.cfg 2016/01/02 v1.6 sample color configuration
30 | )
31 | Package color Info: Driver file: dvips.def on input line 147.
32 |
33 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-def/dvips.def
34 | File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
35 | )
36 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/dvipsnam.def
37 | File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
38 | ))
39 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xcolor/xcolor.sty
40 | Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
41 |
42 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
43 | File: color.cfg 2016/01/02 v1.6 sample color configuration
44 | )
45 | Package xcolor Info: Driver file: dvips.def on input line 225.
46 | LaTeX Info: Redefining \color on input line 709.
47 | Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
48 | Package xcolor Info: Model `RGB' extended on input line 1364.
49 | Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
50 | Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
51 | Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
52 | Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
53 | Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
54 | Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
55 | )
56 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/soul/soul.sty
57 | Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
58 | \SOUL@word=\toks14
59 | \SOUL@lasttoken=\toks15
60 | \SOUL@cmds=\toks16
61 | \SOUL@buffer=\toks17
62 | \SOUL@token=\toks18
63 | \SOUL@spaceskip=\skip43
64 | \SOUL@ttwidth=\dimen103
65 | \SOUL@uldp=\dimen104
66 | \SOUL@ulht=\dimen105
67 | )
68 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjustbox.sty
69 | Package: adjustbox 2019/01/04 v1.2 Adjusting TeX boxes (trim, clip, ...)
70 |
71 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xkeyval/xkeyval.sty
72 | Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
73 |
74 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkeyval.tex
75 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkvutils.tex
76 | \XKV@toks=\toks19
77 | \XKV@tempa@toks=\toks20
78 |
79 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/keyval.tex))
80 | \XKV@depth=\count88
81 | File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
82 | ))
83 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjcalc.sty
84 | Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
85 | -ends (calc, etex, pgfmath)
86 | )
87 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/trimclip.sty
88 | Package: trimclip 2018/04/08 v1.1 Trim and clip general TeX material
89 |
90 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphicx.sty
91 | Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
92 |
93 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphics.sty
94 | Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
95 |
96 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/trig.sty
97 | Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
98 | )
99 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
100 | File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
101 | )
102 | Package graphics Info: Driver file: dvips.def on input line 99.
103 | )
104 | \Gin@req@height=\dimen106
105 | \Gin@req@width=\dimen107
106 | ) (/usr/local/texlive/2019basic/texmf-dist/tex/latex/collectbox/collectbox.sty
107 | Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
108 | \collectedbox=\box27
109 | )
110 | \tc@llx=\dimen108
111 | \tc@lly=\dimen109
112 | \tc@urx=\dimen110
113 | \tc@ury=\dimen111
114 | Package trimclip Info: Using driver 'tc-dvips.def'.
115 |
116 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/tc-dvips.def
117 | File: tc-dvips.def 2019/01/04 v2.2 Clipping driver for dvips
118 | ))
119 | \adjbox@Width=\dimen112
120 | \adjbox@Height=\dimen113
121 | \adjbox@Depth=\dimen114
122 | \adjbox@Totalheight=\dimen115
123 | \adjbox@pwidth=\dimen116
124 | \adjbox@pheight=\dimen117
125 | \adjbox@pdepth=\dimen118
126 | \adjbox@ptotalheight=\dimen119
127 | )
128 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
129 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3.sty
130 | Package: expl3 2019-04-06 L3 programming layer (loader)
131 |
132 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3-code.tex
133 | Package: expl3 2019-04-06 L3 programming layer (code)
134 | \c_max_int=\count89
135 | \l_tmpa_int=\count90
136 | \l_tmpb_int=\count91
137 | \g_tmpa_int=\count92
138 | \g_tmpb_int=\count93
139 | \g__kernel_prg_map_int=\count94
140 | \c__ior_term_ior=\count95
141 | \c_log_iow=\count96
142 | \l_iow_line_count_int=\count97
143 | \l__iow_line_target_int=\count98
144 | \l__iow_one_indent_int=\count99
145 | \l__iow_indent_int=\count100
146 | \c_zero_dim=\dimen120
147 | \c_max_dim=\dimen121
148 | \l_tmpa_dim=\dimen122
149 | \l_tmpb_dim=\dimen123
150 | \g_tmpa_dim=\dimen124
151 | \g_tmpb_dim=\dimen125
152 | \c_zero_skip=\skip44
153 | \c_max_skip=\skip45
154 | \l_tmpa_skip=\skip46
155 | \l_tmpb_skip=\skip47
156 | \g_tmpa_skip=\skip48
157 | \g_tmpb_skip=\skip49
158 | \c_zero_muskip=\muskip10
159 | \c_max_muskip=\muskip11
160 | \l_tmpa_muskip=\muskip12
161 | \l_tmpb_muskip=\muskip13
162 | \g_tmpa_muskip=\muskip14
163 | \g_tmpb_muskip=\muskip15
164 | \l_keys_choice_int=\count101
165 | \l__intarray_loop_int=\count102
166 | \c__intarray_sp_dim=\dimen126
167 | \g__intarray_font_int=\count103
168 | \c__fp_leading_shift_int=\count104
169 | \c__fp_middle_shift_int=\count105
170 | \c__fp_trailing_shift_int=\count106
171 | \c__fp_big_leading_shift_int=\count107
172 | \c__fp_big_middle_shift_int=\count108
173 | \c__fp_big_trailing_shift_int=\count109
174 | \c__fp_Bigg_leading_shift_int=\count110
175 | \c__fp_Bigg_middle_shift_int=\count111
176 | \c__fp_Bigg_trailing_shift_int=\count112
177 | \c__kernel_randint_max_int=\count113
178 | \g__fp_array_int=\count114
179 | \l__fp_array_loop_int=\count115
180 | \l__sort_length_int=\count116
181 | \l__sort_min_int=\count117
182 | \l__sort_top_int=\count118
183 | \l__sort_max_int=\count119
184 | \l__sort_true_max_int=\count120
185 | \l__sort_block_int=\count121
186 | \l__sort_begin_int=\count122
187 | \l__sort_end_int=\count123
188 | \l__sort_A_int=\count124
189 | \l__sort_B_int=\count125
190 | \l__sort_C_int=\count126
191 | \l__tl_analysis_normal_int=\count127
192 | \l__tl_analysis_index_int=\count128
193 | \l__tl_analysis_nesting_int=\count129
194 | \l__tl_analysis_type_int=\count130
195 | \l__regex_internal_a_int=\count131
196 | \l__regex_internal_b_int=\count132
197 | \l__regex_internal_c_int=\count133
198 | \l__regex_balance_int=\count134
199 | \l__regex_group_level_int=\count135
200 | \l__regex_mode_int=\count136
201 | \c__regex_cs_in_class_mode_int=\count137
202 | \c__regex_cs_mode_int=\count138
203 | \l__regex_catcodes_int=\count139
204 | \l__regex_default_catcodes_int=\count140
205 | \c__regex_catcode_D_int=\count141
206 | \c__regex_catcode_S_int=\count142
207 | \c__regex_catcode_L_int=\count143
208 | \c__regex_catcode_O_int=\count144
209 | \c__regex_catcode_A_int=\count145
210 | \c__regex_all_catcodes_int=\count146
211 | \l__regex_show_lines_int=\count147
212 | \l__regex_min_state_int=\count148
213 | \l__regex_max_state_int=\count149
214 | \l__regex_left_state_int=\count150
215 | \l__regex_right_state_int=\count151
216 | \l__regex_capturing_group_int=\count152
217 | \l__regex_min_pos_int=\count153
218 | \l__regex_max_pos_int=\count154
219 | \l__regex_curr_pos_int=\count155
220 | \l__regex_start_pos_int=\count156
221 | \l__regex_success_pos_int=\count157
222 | \l__regex_curr_char_int=\count158
223 | \l__regex_curr_catcode_int=\count159
224 | \l__regex_last_char_int=\count160
225 | \l__regex_case_changed_char_int=\count161
226 | \l__regex_curr_state_int=\count162
227 | \l__regex_step_int=\count163
228 | \l__regex_min_active_int=\count164
229 | \l__regex_max_active_int=\count165
230 | \l__regex_replacement_csnames_int=\count166
231 | \l__regex_match_count_int=\count167
232 | \l__regex_min_submatch_int=\count168
233 | \l__regex_submatch_int=\count169
234 | \l__regex_zeroth_submatch_int=\count170
235 | \g__regex_trace_regex_int=\count171
236 | \c_empty_box=\box28
237 | \l_tmpa_box=\box29
238 | \l_tmpb_box=\box30
239 | \g_tmpa_box=\box31
240 | \g_tmpb_box=\box32
241 | \l__box_top_dim=\dimen127
242 | \l__box_bottom_dim=\dimen128
243 | \l__box_left_dim=\dimen129
244 | \l__box_right_dim=\dimen130
245 | \l__box_top_new_dim=\dimen131
246 | \l__box_bottom_new_dim=\dimen132
247 | \l__box_left_new_dim=\dimen133
248 | \l__box_right_new_dim=\dimen134
249 | \l__box_internal_box=\box33
250 | \l__coffin_internal_box=\box34
251 | \l__coffin_internal_dim=\dimen135
252 | \l__coffin_offset_x_dim=\dimen136
253 | \l__coffin_offset_y_dim=\dimen137
254 | \l__coffin_x_dim=\dimen138
255 | \l__coffin_y_dim=\dimen139
256 | \l__coffin_x_prime_dim=\dimen140
257 | \l__coffin_y_prime_dim=\dimen141
258 | \c_empty_coffin=\box35
259 | \l__coffin_aligned_coffin=\box36
260 | \l__coffin_aligned_internal_coffin=\box37
261 | \l_tmpa_coffin=\box38
262 | \l_tmpb_coffin=\box39
263 | \g_tmpa_coffin=\box40
264 | \g_tmpb_coffin=\box41
265 | \l__coffin_bounding_shift_dim=\dimen142
266 | \l__coffin_left_corner_dim=\dimen143
267 | \l__coffin_right_corner_dim=\dimen144
268 | \l__coffin_bottom_corner_dim=\dimen145
269 | \l__coffin_top_corner_dim=\dimen146
270 | \l__coffin_scaled_total_height_dim=\dimen147
271 | \l__coffin_scaled_width_dim=\dimen148
272 | \c__coffin_empty_coffin=\box42
273 | \l__coffin_display_coffin=\box43
274 | \l__coffin_display_coord_coffin=\box44
275 | \l__coffin_display_pole_coffin=\box45
276 | \l__coffin_display_offset_dim=\dimen149
277 | \l__coffin_display_x_dim=\dimen150
278 | \l__coffin_display_y_dim=\dimen151
279 | \g__file_internal_ior=\read1
280 | \l__seq_internal_a_int=\count172
281 | \l__seq_internal_b_int=\count173
282 | \c__deprecation_minus_one=\count174
283 | )
284 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/l3dvips.def
285 | File: l3dvips.def 2019-04-06 v L3 Experimental driver: dvips
286 | \g__driver_pdf_object_int=\count175
287 | ))
288 | Package: xparse 2019-03-05 L3 Experimental document command parser
289 | \l__xparse_current_arg_int=\count176
290 | \g__xparse_grabber_int=\count177
291 | \l__xparse_m_args_int=\count178
292 | \l__xparse_v_nesting_int=\count179
293 | )
294 | (resources/4a.aux)
295 | \openout1 = `4a.aux'.
296 |
297 | LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 52.
298 | LaTeX Font Info: ... okay on input line 52.
299 | LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 52.
300 | LaTeX Font Info: ... okay on input line 52.
301 | LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 52.
302 | LaTeX Font Info: ... okay on input line 52.
303 | LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 52.
304 | LaTeX Font Info: ... okay on input line 52.
305 | LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 52.
306 | LaTeX Font Info: ... okay on input line 52.
307 | LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 52.
308 | LaTeX Font Info: ... okay on input line 52.
309 | LaTeX Font Info: External font `cmex10' loaded for size
310 | (Font) <7> on input line 53.
311 | LaTeX Font Info: External font `cmex10' loaded for size
312 | (Font) <5> on input line 53.
313 | [1
314 |
315 | ] (resources/4a.aux) )
316 | Here is how much of TeX's memory you used:
317 | 11740 strings out of 494061
318 | 220339 string characters out of 6163061
319 | 243554 words of memory out of 5000000
320 | 15445 multiletter control sequences out of 15000+600000
321 | 532651 words of font info for 25 fonts, out of 8000000 for 9000
322 | 319 hyphenation exceptions out of 8191
323 | 40i,5n,63p,265b,317s stack positions out of 5000i,500n,10000p,200000b,80000s
324 |
325 | Output written on resources/4a.dvi (1 page, 400 bytes).
326 |
--------------------------------------------------------------------------------
/test/resources/4a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/4a.png
--------------------------------------------------------------------------------
/test/resources/4a.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 | \documentclass{article}
17 | \usepackage[usenames]{color}
18 | \pagestyle{empty} % do not remove
19 | % The settings below are copied from fullpage.sty
20 | \setlength{\textwidth}{\paperwidth}
21 | \addtolength{\textwidth}{-3cm}
22 | \setlength{\oddsidemargin}{1.5cm}
23 | \addtolength{\oddsidemargin}{-2.54cm}
24 | \setlength{\evensidemargin}{\oddsidemargin}
25 | \setlength{\textheight}{\paperheight}
26 | \addtolength{\textheight}{-\headheight}
27 | \addtolength{\textheight}{-\headsep}
28 | \addtolength{\textheight}{-\footskip}
29 | \addtolength{\textheight}{-3cm}
30 | \setlength{\topmargin}{1.5cm}
31 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
32 | \usepackage{xcolor}
33 | %\setlength{\fboxsep}{0pt}
34 | \usepackage{soul}
35 | \usepackage{adjustbox}
36 |
37 | \usepackage{xparse}
38 |
39 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
40 | \begingroup\colorlet{currcolor}{.}%
41 | \IfValueTF{#1}
42 | {\textcolor[#1]{#2}}
43 | {\textcolor{#2}}
44 | {%
45 | #3% the nucleus
46 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
47 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
48 | }%
49 | \endgroup
50 | }
51 |
52 | \begin{document}
53 | \[ 4a \]
54 | \end{document}
--------------------------------------------------------------------------------
/test/resources/alignstar.org:
--------------------------------------------------------------------------------
1 | * Align* eq
2 | \begin{align*}
3 | \cmt{45 + i} 45 + i
4 | \end{align*}
5 |
--------------------------------------------------------------------------------
/test/resources/auto/2a.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "2a"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "xparse")
15 | (TeX-add-symbols
16 | '("cmt" 1)
17 | "colornucleus")
18 | (LaTeX-add-xcolor-definecolors
19 | "currcolor"
20 | "fg"
21 | "bg"))
22 | :latex)
23 |
24 |
--------------------------------------------------------------------------------
/test/resources/auto/2a_commented.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "2a_commented"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "xparse"))
15 | :latex)
16 |
17 |
--------------------------------------------------------------------------------
/test/resources/auto/4a.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "4a"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "xparse")
15 | (TeX-add-symbols
16 | "colornucleus")
17 | (LaTeX-add-xcolor-definecolors
18 | "currcolor"))
19 | :latex)
20 |
21 |
--------------------------------------------------------------------------------
/test/resources/auto/f_x.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "f_x"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "xparse")
15 | (TeX-add-symbols
16 | "colornucleus")
17 | (LaTeX-add-xcolor-definecolors
18 | "currcolor"))
19 | :latex)
20 |
21 |
--------------------------------------------------------------------------------
/test/resources/auto/joules.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "joules"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "siunitx"
15 | "amsmath"
16 | "xparse")
17 | (TeX-add-symbols
18 | '("cmt" 1)))
19 | :latex)
20 |
21 |
--------------------------------------------------------------------------------
/test/resources/auto/pythag.el:
--------------------------------------------------------------------------------
1 | (TeX-add-style-hook
2 | "pythag"
3 | (lambda ()
4 | (TeX-add-to-alist 'LaTeX-provided-package-options
5 | '(("color" "usenames")))
6 | (TeX-run-style-hooks
7 | "latex2e"
8 | "article"
9 | "art10"
10 | "color"
11 | "xcolor"
12 | "soul"
13 | "adjustbox"
14 | "xparse"))
15 | :latex)
16 |
17 |
--------------------------------------------------------------------------------
/test/resources/f_x.log:
--------------------------------------------------------------------------------
1 | This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex 2019.5.19) 28 SEP 2019 08:19
2 | entering extended mode
3 | restricted \write18 enabled.
4 | %&-line parsing enabled.
5 | **resources/f_x.tex
6 | (./resources/f_x.tex
7 | LaTeX2e <2018-12-01>
8 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/article.cls
9 | Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
10 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/size10.clo
11 | File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
12 | )
13 | \c@part=\count80
14 | \c@section=\count81
15 | \c@subsection=\count82
16 | \c@subsubsection=\count83
17 | \c@paragraph=\count84
18 | \c@subparagraph=\count85
19 | \c@figure=\count86
20 | \c@table=\count87
21 | \abovecaptionskip=\skip41
22 | \belowcaptionskip=\skip42
23 | \bibindent=\dimen102
24 | )
25 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/color.sty
26 | Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
27 |
28 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
29 | File: color.cfg 2016/01/02 v1.6 sample color configuration
30 | )
31 | Package color Info: Driver file: dvips.def on input line 147.
32 |
33 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-def/dvips.def
34 | File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
35 | )
36 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/dvipsnam.def
37 | File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
38 | ))
39 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xcolor/xcolor.sty
40 | Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
41 |
42 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
43 | File: color.cfg 2016/01/02 v1.6 sample color configuration
44 | )
45 | Package xcolor Info: Driver file: dvips.def on input line 225.
46 | LaTeX Info: Redefining \color on input line 709.
47 | Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
48 | Package xcolor Info: Model `RGB' extended on input line 1364.
49 | Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
50 | Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
51 | Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
52 | Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
53 | Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
54 | Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
55 | )
56 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/soul/soul.sty
57 | Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
58 | \SOUL@word=\toks14
59 | \SOUL@lasttoken=\toks15
60 | \SOUL@cmds=\toks16
61 | \SOUL@buffer=\toks17
62 | \SOUL@token=\toks18
63 | \SOUL@spaceskip=\skip43
64 | \SOUL@ttwidth=\dimen103
65 | \SOUL@uldp=\dimen104
66 | \SOUL@ulht=\dimen105
67 | )
68 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjustbox.sty
69 | Package: adjustbox 2019/01/04 v1.2 Adjusting TeX boxes (trim, clip, ...)
70 |
71 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xkeyval/xkeyval.sty
72 | Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
73 |
74 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkeyval.tex
75 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkvutils.tex
76 | \XKV@toks=\toks19
77 | \XKV@tempa@toks=\toks20
78 |
79 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/keyval.tex))
80 | \XKV@depth=\count88
81 | File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
82 | ))
83 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjcalc.sty
84 | Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
85 | -ends (calc, etex, pgfmath)
86 | )
87 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/trimclip.sty
88 | Package: trimclip 2018/04/08 v1.1 Trim and clip general TeX material
89 |
90 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphicx.sty
91 | Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
92 |
93 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphics.sty
94 | Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
95 |
96 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/trig.sty
97 | Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
98 | )
99 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
100 | File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
101 | )
102 | Package graphics Info: Driver file: dvips.def on input line 99.
103 | )
104 | \Gin@req@height=\dimen106
105 | \Gin@req@width=\dimen107
106 | ) (/usr/local/texlive/2019basic/texmf-dist/tex/latex/collectbox/collectbox.sty
107 | Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
108 | \collectedbox=\box27
109 | )
110 | \tc@llx=\dimen108
111 | \tc@lly=\dimen109
112 | \tc@urx=\dimen110
113 | \tc@ury=\dimen111
114 | Package trimclip Info: Using driver 'tc-dvips.def'.
115 |
116 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/tc-dvips.def
117 | File: tc-dvips.def 2019/01/04 v2.2 Clipping driver for dvips
118 | ))
119 | \adjbox@Width=\dimen112
120 | \adjbox@Height=\dimen113
121 | \adjbox@Depth=\dimen114
122 | \adjbox@Totalheight=\dimen115
123 | \adjbox@pwidth=\dimen116
124 | \adjbox@pheight=\dimen117
125 | \adjbox@pdepth=\dimen118
126 | \adjbox@ptotalheight=\dimen119
127 | )
128 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
129 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3.sty
130 | Package: expl3 2019-04-06 L3 programming layer (loader)
131 |
132 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3-code.tex
133 | Package: expl3 2019-04-06 L3 programming layer (code)
134 | \c_max_int=\count89
135 | \l_tmpa_int=\count90
136 | \l_tmpb_int=\count91
137 | \g_tmpa_int=\count92
138 | \g_tmpb_int=\count93
139 | \g__kernel_prg_map_int=\count94
140 | \c__ior_term_ior=\count95
141 | \c_log_iow=\count96
142 | \l_iow_line_count_int=\count97
143 | \l__iow_line_target_int=\count98
144 | \l__iow_one_indent_int=\count99
145 | \l__iow_indent_int=\count100
146 | \c_zero_dim=\dimen120
147 | \c_max_dim=\dimen121
148 | \l_tmpa_dim=\dimen122
149 | \l_tmpb_dim=\dimen123
150 | \g_tmpa_dim=\dimen124
151 | \g_tmpb_dim=\dimen125
152 | \c_zero_skip=\skip44
153 | \c_max_skip=\skip45
154 | \l_tmpa_skip=\skip46
155 | \l_tmpb_skip=\skip47
156 | \g_tmpa_skip=\skip48
157 | \g_tmpb_skip=\skip49
158 | \c_zero_muskip=\muskip10
159 | \c_max_muskip=\muskip11
160 | \l_tmpa_muskip=\muskip12
161 | \l_tmpb_muskip=\muskip13
162 | \g_tmpa_muskip=\muskip14
163 | \g_tmpb_muskip=\muskip15
164 | \l_keys_choice_int=\count101
165 | \l__intarray_loop_int=\count102
166 | \c__intarray_sp_dim=\dimen126
167 | \g__intarray_font_int=\count103
168 | \c__fp_leading_shift_int=\count104
169 | \c__fp_middle_shift_int=\count105
170 | \c__fp_trailing_shift_int=\count106
171 | \c__fp_big_leading_shift_int=\count107
172 | \c__fp_big_middle_shift_int=\count108
173 | \c__fp_big_trailing_shift_int=\count109
174 | \c__fp_Bigg_leading_shift_int=\count110
175 | \c__fp_Bigg_middle_shift_int=\count111
176 | \c__fp_Bigg_trailing_shift_int=\count112
177 | \c__kernel_randint_max_int=\count113
178 | \g__fp_array_int=\count114
179 | \l__fp_array_loop_int=\count115
180 | \l__sort_length_int=\count116
181 | \l__sort_min_int=\count117
182 | \l__sort_top_int=\count118
183 | \l__sort_max_int=\count119
184 | \l__sort_true_max_int=\count120
185 | \l__sort_block_int=\count121
186 | \l__sort_begin_int=\count122
187 | \l__sort_end_int=\count123
188 | \l__sort_A_int=\count124
189 | \l__sort_B_int=\count125
190 | \l__sort_C_int=\count126
191 | \l__tl_analysis_normal_int=\count127
192 | \l__tl_analysis_index_int=\count128
193 | \l__tl_analysis_nesting_int=\count129
194 | \l__tl_analysis_type_int=\count130
195 | \l__regex_internal_a_int=\count131
196 | \l__regex_internal_b_int=\count132
197 | \l__regex_internal_c_int=\count133
198 | \l__regex_balance_int=\count134
199 | \l__regex_group_level_int=\count135
200 | \l__regex_mode_int=\count136
201 | \c__regex_cs_in_class_mode_int=\count137
202 | \c__regex_cs_mode_int=\count138
203 | \l__regex_catcodes_int=\count139
204 | \l__regex_default_catcodes_int=\count140
205 | \c__regex_catcode_D_int=\count141
206 | \c__regex_catcode_S_int=\count142
207 | \c__regex_catcode_L_int=\count143
208 | \c__regex_catcode_O_int=\count144
209 | \c__regex_catcode_A_int=\count145
210 | \c__regex_all_catcodes_int=\count146
211 | \l__regex_show_lines_int=\count147
212 | \l__regex_min_state_int=\count148
213 | \l__regex_max_state_int=\count149
214 | \l__regex_left_state_int=\count150
215 | \l__regex_right_state_int=\count151
216 | \l__regex_capturing_group_int=\count152
217 | \l__regex_min_pos_int=\count153
218 | \l__regex_max_pos_int=\count154
219 | \l__regex_curr_pos_int=\count155
220 | \l__regex_start_pos_int=\count156
221 | \l__regex_success_pos_int=\count157
222 | \l__regex_curr_char_int=\count158
223 | \l__regex_curr_catcode_int=\count159
224 | \l__regex_last_char_int=\count160
225 | \l__regex_case_changed_char_int=\count161
226 | \l__regex_curr_state_int=\count162
227 | \l__regex_step_int=\count163
228 | \l__regex_min_active_int=\count164
229 | \l__regex_max_active_int=\count165
230 | \l__regex_replacement_csnames_int=\count166
231 | \l__regex_match_count_int=\count167
232 | \l__regex_min_submatch_int=\count168
233 | \l__regex_submatch_int=\count169
234 | \l__regex_zeroth_submatch_int=\count170
235 | \g__regex_trace_regex_int=\count171
236 | \c_empty_box=\box28
237 | \l_tmpa_box=\box29
238 | \l_tmpb_box=\box30
239 | \g_tmpa_box=\box31
240 | \g_tmpb_box=\box32
241 | \l__box_top_dim=\dimen127
242 | \l__box_bottom_dim=\dimen128
243 | \l__box_left_dim=\dimen129
244 | \l__box_right_dim=\dimen130
245 | \l__box_top_new_dim=\dimen131
246 | \l__box_bottom_new_dim=\dimen132
247 | \l__box_left_new_dim=\dimen133
248 | \l__box_right_new_dim=\dimen134
249 | \l__box_internal_box=\box33
250 | \l__coffin_internal_box=\box34
251 | \l__coffin_internal_dim=\dimen135
252 | \l__coffin_offset_x_dim=\dimen136
253 | \l__coffin_offset_y_dim=\dimen137
254 | \l__coffin_x_dim=\dimen138
255 | \l__coffin_y_dim=\dimen139
256 | \l__coffin_x_prime_dim=\dimen140
257 | \l__coffin_y_prime_dim=\dimen141
258 | \c_empty_coffin=\box35
259 | \l__coffin_aligned_coffin=\box36
260 | \l__coffin_aligned_internal_coffin=\box37
261 | \l_tmpa_coffin=\box38
262 | \l_tmpb_coffin=\box39
263 | \g_tmpa_coffin=\box40
264 | \g_tmpb_coffin=\box41
265 | \l__coffin_bounding_shift_dim=\dimen142
266 | \l__coffin_left_corner_dim=\dimen143
267 | \l__coffin_right_corner_dim=\dimen144
268 | \l__coffin_bottom_corner_dim=\dimen145
269 | \l__coffin_top_corner_dim=\dimen146
270 | \l__coffin_scaled_total_height_dim=\dimen147
271 | \l__coffin_scaled_width_dim=\dimen148
272 | \c__coffin_empty_coffin=\box42
273 | \l__coffin_display_coffin=\box43
274 | \l__coffin_display_coord_coffin=\box44
275 | \l__coffin_display_pole_coffin=\box45
276 | \l__coffin_display_offset_dim=\dimen149
277 | \l__coffin_display_x_dim=\dimen150
278 | \l__coffin_display_y_dim=\dimen151
279 | \g__file_internal_ior=\read1
280 | \l__seq_internal_a_int=\count172
281 | \l__seq_internal_b_int=\count173
282 | \c__deprecation_minus_one=\count174
283 | )
284 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/l3dvips.def
285 | File: l3dvips.def 2019-04-06 v L3 Experimental driver: dvips
286 | \g__driver_pdf_object_int=\count175
287 | ))
288 | Package: xparse 2019-03-05 L3 Experimental document command parser
289 | \l__xparse_current_arg_int=\count176
290 | \g__xparse_grabber_int=\count177
291 | \l__xparse_m_args_int=\count178
292 | \l__xparse_v_nesting_int=\count179
293 | )
294 | No file f_x.aux.
295 | \openout1 = `f_x.aux'.
296 |
297 | LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 52.
298 | LaTeX Font Info: ... okay on input line 52.
299 | LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 52.
300 | LaTeX Font Info: ... okay on input line 52.
301 | LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 52.
302 | LaTeX Font Info: ... okay on input line 52.
303 | LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 52.
304 | LaTeX Font Info: ... okay on input line 52.
305 | LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 52.
306 | LaTeX Font Info: ... okay on input line 52.
307 | LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 52.
308 | LaTeX Font Info: ... okay on input line 52.
309 | LaTeX Font Info: External font `cmex10' loaded for size
310 | (Font) <7> on input line 53.
311 | LaTeX Font Info: External font `cmex10' loaded for size
312 | (Font) <5> on input line 53.
313 | [1
314 |
315 | ] (resources/f_x.aux) )
316 | Here is how much of TeX's memory you used:
317 | 11738 strings out of 494061
318 | 220314 string characters out of 6163061
319 | 243556 words of memory out of 5000000
320 | 15445 multiletter control sequences out of 15000+600000
321 | 532651 words of font info for 25 fonts, out of 8000000 for 9000
322 | 319 hyphenation exceptions out of 8191
323 | 40i,5n,63p,266b,317s stack positions out of 5000i,500n,10000p,200000b,80000s
324 |
325 | Output written on resources/f_x.dvi (1 page, 408 bytes).
326 |
--------------------------------------------------------------------------------
/test/resources/joules.log:
--------------------------------------------------------------------------------
1 | This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex 2019.5.19) 16 DEC 2019 14:17
2 | entering extended mode
3 | restricted \write18 enabled.
4 | %&-line parsing enabled.
5 | **resources/joules.tex
6 | (./resources/joules.tex
7 | LaTeX2e <2018-12-01>
8 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/article.cls
9 | Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
10 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/size10.clo
11 | File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
12 | )
13 | \c@part=\count80
14 | \c@section=\count81
15 | \c@subsection=\count82
16 | \c@subsubsection=\count83
17 | \c@paragraph=\count84
18 | \c@subparagraph=\count85
19 | \c@figure=\count86
20 | \c@table=\count87
21 | \abovecaptionskip=\skip41
22 | \belowcaptionskip=\skip42
23 | \bibindent=\dimen102
24 | )
25 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/color.sty
26 | Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
27 |
28 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
29 | File: color.cfg 2016/01/02 v1.6 sample color configuration
30 | )
31 | Package color Info: Driver file: dvips.def on input line 147.
32 |
33 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-def/dvips.def
34 | File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
35 | )
36 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/dvipsnam.def
37 | File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
38 | ))
39 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xcolor/xcolor.sty
40 | Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
41 |
42 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
43 | File: color.cfg 2016/01/02 v1.6 sample color configuration
44 | )
45 | Package xcolor Info: Driver file: dvips.def on input line 225.
46 | LaTeX Info: Redefining \color on input line 709.
47 | Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
48 | Package xcolor Info: Model `RGB' extended on input line 1364.
49 | Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
50 | Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
51 | Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
52 | Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
53 | Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
54 | Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
55 | )
56 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/soul/soul.sty
57 | Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
58 | \SOUL@word=\toks14
59 | \SOUL@lasttoken=\toks15
60 | \SOUL@cmds=\toks16
61 | \SOUL@buffer=\toks17
62 | \SOUL@token=\toks18
63 | \SOUL@spaceskip=\skip43
64 | \SOUL@ttwidth=\dimen103
65 | \SOUL@uldp=\dimen104
66 | \SOUL@ulht=\dimen105
67 | )
68 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjustbox.sty
69 | Package: adjustbox 2019/01/04 v1.2 Adjusting TeX boxes (trim, clip, ...)
70 |
71 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xkeyval/xkeyval.sty
72 | Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
73 |
74 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkeyval.tex
75 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkvutils.tex
76 | \XKV@toks=\toks19
77 | \XKV@tempa@toks=\toks20
78 |
79 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/keyval.tex))
80 | \XKV@depth=\count88
81 | File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
82 | ))
83 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjcalc.sty
84 | Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
85 | -ends (calc, etex, pgfmath)
86 | )
87 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/trimclip.sty
88 | Package: trimclip 2018/04/08 v1.1 Trim and clip general TeX material
89 |
90 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphicx.sty
91 | Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
92 |
93 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphics.sty
94 | Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
95 |
96 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/trig.sty
97 | Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
98 | )
99 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
100 | File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
101 | )
102 | Package graphics Info: Driver file: dvips.def on input line 99.
103 | )
104 | \Gin@req@height=\dimen106
105 | \Gin@req@width=\dimen107
106 | ) (/usr/local/texlive/2019basic/texmf-dist/tex/latex/collectbox/collectbox.sty
107 | Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
108 | \collectedbox=\box27
109 | )
110 | \tc@llx=\dimen108
111 | \tc@lly=\dimen109
112 | \tc@urx=\dimen110
113 | \tc@ury=\dimen111
114 | Package trimclip Info: Using driver 'tc-dvips.def'.
115 |
116 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/tc-dvips.def
117 | File: tc-dvips.def 2019/01/04 v2.2 Clipping driver for dvips
118 | ))
119 | \adjbox@Width=\dimen112
120 | \adjbox@Height=\dimen113
121 | \adjbox@Depth=\dimen114
122 | \adjbox@Totalheight=\dimen115
123 | \adjbox@pwidth=\dimen116
124 | \adjbox@pheight=\dimen117
125 | \adjbox@pdepth=\dimen118
126 | \adjbox@ptotalheight=\dimen119
127 | )
128 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/siunitx/siunitx.sty
129 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3.sty
130 | Package: expl3 2019-04-06 L3 programming layer (loader)
131 |
132 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3-code.tex
133 | Package: expl3 2019-04-06 L3 programming layer (code)
134 | \c_max_int=\count89
135 | \l_tmpa_int=\count90
136 | \l_tmpb_int=\count91
137 | \g_tmpa_int=\count92
138 | \g_tmpb_int=\count93
139 | \g__kernel_prg_map_int=\count94
140 | \c__ior_term_ior=\count95
141 | \c_log_iow=\count96
142 | \l_iow_line_count_int=\count97
143 | \l__iow_line_target_int=\count98
144 | \l__iow_one_indent_int=\count99
145 | \l__iow_indent_int=\count100
146 | \c_zero_dim=\dimen120
147 | \c_max_dim=\dimen121
148 | \l_tmpa_dim=\dimen122
149 | \l_tmpb_dim=\dimen123
150 | \g_tmpa_dim=\dimen124
151 | \g_tmpb_dim=\dimen125
152 | \c_zero_skip=\skip44
153 | \c_max_skip=\skip45
154 | \l_tmpa_skip=\skip46
155 | \l_tmpb_skip=\skip47
156 | \g_tmpa_skip=\skip48
157 | \g_tmpb_skip=\skip49
158 | \c_zero_muskip=\muskip10
159 | \c_max_muskip=\muskip11
160 | \l_tmpa_muskip=\muskip12
161 | \l_tmpb_muskip=\muskip13
162 | \g_tmpa_muskip=\muskip14
163 | \g_tmpb_muskip=\muskip15
164 | \l_keys_choice_int=\count101
165 | \l__intarray_loop_int=\count102
166 | \c__intarray_sp_dim=\dimen126
167 | \g__intarray_font_int=\count103
168 | \c__fp_leading_shift_int=\count104
169 | \c__fp_middle_shift_int=\count105
170 | \c__fp_trailing_shift_int=\count106
171 | \c__fp_big_leading_shift_int=\count107
172 | \c__fp_big_middle_shift_int=\count108
173 | \c__fp_big_trailing_shift_int=\count109
174 | \c__fp_Bigg_leading_shift_int=\count110
175 | \c__fp_Bigg_middle_shift_int=\count111
176 | \c__fp_Bigg_trailing_shift_int=\count112
177 | \c__kernel_randint_max_int=\count113
178 | \g__fp_array_int=\count114
179 | \l__fp_array_loop_int=\count115
180 | \l__sort_length_int=\count116
181 | \l__sort_min_int=\count117
182 | \l__sort_top_int=\count118
183 | \l__sort_max_int=\count119
184 | \l__sort_true_max_int=\count120
185 | \l__sort_block_int=\count121
186 | \l__sort_begin_int=\count122
187 | \l__sort_end_int=\count123
188 | \l__sort_A_int=\count124
189 | \l__sort_B_int=\count125
190 | \l__sort_C_int=\count126
191 | \l__tl_analysis_normal_int=\count127
192 | \l__tl_analysis_index_int=\count128
193 | \l__tl_analysis_nesting_int=\count129
194 | \l__tl_analysis_type_int=\count130
195 | \l__regex_internal_a_int=\count131
196 | \l__regex_internal_b_int=\count132
197 | \l__regex_internal_c_int=\count133
198 | \l__regex_balance_int=\count134
199 | \l__regex_group_level_int=\count135
200 | \l__regex_mode_int=\count136
201 | \c__regex_cs_in_class_mode_int=\count137
202 | \c__regex_cs_mode_int=\count138
203 | \l__regex_catcodes_int=\count139
204 | \l__regex_default_catcodes_int=\count140
205 | \c__regex_catcode_D_int=\count141
206 | \c__regex_catcode_S_int=\count142
207 | \c__regex_catcode_L_int=\count143
208 | \c__regex_catcode_O_int=\count144
209 | \c__regex_catcode_A_int=\count145
210 | \c__regex_all_catcodes_int=\count146
211 | \l__regex_show_lines_int=\count147
212 | \l__regex_min_state_int=\count148
213 | \l__regex_max_state_int=\count149
214 | \l__regex_left_state_int=\count150
215 | \l__regex_right_state_int=\count151
216 | \l__regex_capturing_group_int=\count152
217 | \l__regex_min_pos_int=\count153
218 | \l__regex_max_pos_int=\count154
219 | \l__regex_curr_pos_int=\count155
220 | \l__regex_start_pos_int=\count156
221 | \l__regex_success_pos_int=\count157
222 | \l__regex_curr_char_int=\count158
223 | \l__regex_curr_catcode_int=\count159
224 | \l__regex_last_char_int=\count160
225 | \l__regex_case_changed_char_int=\count161
226 | \l__regex_curr_state_int=\count162
227 | \l__regex_step_int=\count163
228 | \l__regex_min_active_int=\count164
229 | \l__regex_max_active_int=\count165
230 | \l__regex_replacement_csnames_int=\count166
231 | \l__regex_match_count_int=\count167
232 | \l__regex_min_submatch_int=\count168
233 | \l__regex_submatch_int=\count169
234 | \l__regex_zeroth_submatch_int=\count170
235 | \g__regex_trace_regex_int=\count171
236 | \c_empty_box=\box28
237 | \l_tmpa_box=\box29
238 | \l_tmpb_box=\box30
239 | \g_tmpa_box=\box31
240 | \g_tmpb_box=\box32
241 | \l__box_top_dim=\dimen127
242 | \l__box_bottom_dim=\dimen128
243 | \l__box_left_dim=\dimen129
244 | \l__box_right_dim=\dimen130
245 | \l__box_top_new_dim=\dimen131
246 | \l__box_bottom_new_dim=\dimen132
247 | \l__box_left_new_dim=\dimen133
248 | \l__box_right_new_dim=\dimen134
249 | \l__box_internal_box=\box33
250 | \l__coffin_internal_box=\box34
251 | \l__coffin_internal_dim=\dimen135
252 | \l__coffin_offset_x_dim=\dimen136
253 | \l__coffin_offset_y_dim=\dimen137
254 | \l__coffin_x_dim=\dimen138
255 | \l__coffin_y_dim=\dimen139
256 | \l__coffin_x_prime_dim=\dimen140
257 | \l__coffin_y_prime_dim=\dimen141
258 | \c_empty_coffin=\box35
259 | \l__coffin_aligned_coffin=\box36
260 | \l__coffin_aligned_internal_coffin=\box37
261 | \l_tmpa_coffin=\box38
262 | \l_tmpb_coffin=\box39
263 | \g_tmpa_coffin=\box40
264 | \g_tmpb_coffin=\box41
265 | \l__coffin_bounding_shift_dim=\dimen142
266 | \l__coffin_left_corner_dim=\dimen143
267 | \l__coffin_right_corner_dim=\dimen144
268 | \l__coffin_bottom_corner_dim=\dimen145
269 | \l__coffin_top_corner_dim=\dimen146
270 | \l__coffin_scaled_total_height_dim=\dimen147
271 | \l__coffin_scaled_width_dim=\dimen148
272 | \c__coffin_empty_coffin=\box42
273 | \l__coffin_display_coffin=\box43
274 | \l__coffin_display_coord_coffin=\box44
275 | \l__coffin_display_pole_coffin=\box45
276 | \l__coffin_display_offset_dim=\dimen149
277 | \l__coffin_display_x_dim=\dimen150
278 | \l__coffin_display_y_dim=\dimen151
279 | \g__file_internal_ior=\read1
280 | \l__seq_internal_a_int=\count172
281 | \l__seq_internal_b_int=\count173
282 | \c__deprecation_minus_one=\count174
283 | )
284 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/l3dvips.def
285 | File: l3dvips.def 2019-04-06 v L3 Experimental driver: dvips
286 | \g__driver_pdf_object_int=\count175
287 | ))
288 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
289 | Package: xparse 2019-03-05 L3 Experimental document command parser
290 | \l__xparse_current_arg_int=\count176
291 | \g__xparse_grabber_int=\count177
292 | \l__xparse_m_args_int=\count178
293 | \l__xparse_v_nesting_int=\count179
294 | )
295 | Package: siunitx 2018/05/17 v2.7s A comprehensive (SI) units package
296 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/amsmath/amstext.sty
297 | Package: amstext 2000/06/29 v2.01 AMS text
298 |
299 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/amsmath/amsgen.sty
300 | File: amsgen.sty 1999/11/30 v2.0 generic functions
301 | \@emptytoks=\toks21
302 | \ex@=\dimen152
303 | ))
304 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/tools/array.sty
305 | Package: array 2018/12/30 v2.4k Tabular extension package (FMi)
306 | \col@sep=\dimen153
307 | \ar@mcellbox=\box46
308 | \extrarowheight=\dimen154
309 | \NC@list=\toks22
310 | \extratabsurround=\skip50
311 | \backup@length=\skip51
312 | \ar@cellbox=\box47
313 | )
314 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e
315 | .sty
316 | Package: l3keys2e 2019-03-05 LaTeX2e option processing using LaTeX3 keys
317 | )
318 | \l__siunitx_tmp_box=\box48
319 | \l__siunitx_tmp_dim=\dimen155
320 | \l__siunitx_tmp_int=\count180
321 | \l__siunitx_number_mantissa_length_int=\count181
322 | \l__siunitx_number_uncert_length_int=\count182
323 | \l__siunitx_round_int=\count183
324 | \l__siunitx_process_decimal_int=\count184
325 | \l__siunitx_process_uncertainty_int=\count185
326 | \l__siunitx_process_fixed_int=\count186
327 | \l__siunitx_process_integer_min_int=\count187
328 | \l__siunitx_process_precision_int=\count188
329 | \l__siunitx_group_min_int=\count189
330 | \l__siunitx_angle_marker_box=\box49
331 | \l__siunitx_angle_unit_box=\box50
332 | \l__siunitx_angle_marker_dim=\dimen156
333 | \l__siunitx_angle_unit_dim=\dimen157
334 | \l__siunitx_unit_int=\count190
335 | \l__siunitx_unit_denominator_int=\count191
336 | \l__siunitx_unit_numerator_int=\count192
337 | \l__siunitx_unit_prefix_int=\count193
338 | \l__siunitx_unit_prefix_base_int=\count194
339 | \l__siunitx_unit_prefix_gram_int=\count195
340 | \l__siunitx_number_product_int=\count196
341 | \c__siunitx_one_fill_skip=\skip52
342 | \l__siunitx_table_unit_align_skip=\skip53
343 | \l__siunitx_table_exponent_dim=\dimen158
344 | \l__siunitx_table_integer_dim=\dimen159
345 | \l__siunitx_table_mantissa_dim=\dimen160
346 | \l__siunitx_table_marker_dim=\dimen161
347 | \l__siunitx_table_result_dim=\dimen162
348 | \l__siunitx_table_uncert_dim=\dimen163
349 | \l__siunitx_table_fill_pre_dim=\dimen164
350 | \l__siunitx_table_fill_post_dim=\dimen165
351 | \l__siunitx_table_fill_mid_dim=\dimen166
352 | \l__siunitx_table_pre_box=\box51
353 | \l__siunitx_table_post_box=\box52
354 | \l__siunitx_table_mantissa_box=\box53
355 | \l__siunitx_table_result_box=\box54
356 | \l__siunitx_table_number_align_skip=\skip54
357 | \l__siunitx_table_text_align_skip=\skip55
358 |
359 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/translator/translator.sty
360 | Package: translator 2018/01/04 v1.12 Easy translation of strings in LaTeX
361 | ))
362 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/amsmath/amsmath.sty
363 | Package: amsmath 2018/12/01 v2.17b AMS math features
364 | \@mathmargin=\skip56
365 |
366 | For additional information on amsmath, use the `?' option.
367 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/amsmath/amsbsy.sty
368 | Package: amsbsy 1999/11/29 v1.2d Bold Symbols
369 | \pmbraise@=\dimen167
370 | )
371 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/amsmath/amsopn.sty
372 | Package: amsopn 2016/03/08 v2.02 operator names
373 | )
374 | \inf@bad=\count197
375 | LaTeX Info: Redefining \frac on input line 223.
376 | \uproot@=\count198
377 | \leftroot@=\count199
378 | LaTeX Info: Redefining \overline on input line 385.
379 | \classnum@=\count266
380 | \DOTSCASE@=\count267
381 | LaTeX Info: Redefining \ldots on input line 482.
382 | LaTeX Info: Redefining \dots on input line 485.
383 | LaTeX Info: Redefining \cdots on input line 606.
384 | \Mathstrutbox@=\box55
385 | \strutbox@=\box56
386 | \big@size=\dimen168
387 | LaTeX Font Info: Redeclaring font encoding OML on input line 729.
388 | LaTeX Font Info: Redeclaring font encoding OMS on input line 730.
389 | \macc@depth=\count268
390 | \c@MaxMatrixCols=\count269
391 | \dotsspace@=\muskip16
392 | \c@parentequation=\count270
393 | \dspbrk@lvl=\count271
394 | \tag@help=\toks23
395 | \row@=\count272
396 | \column@=\count273
397 | \maxfields@=\count274
398 | \andhelp@=\toks24
399 | \eqnshift@=\dimen169
400 | \alignsep@=\dimen170
401 | \tagshift@=\dimen171
402 | \tagwidth@=\dimen172
403 | \totwidth@=\dimen173
404 | \lineht@=\dimen174
405 | \@envbody=\toks25
406 | \multlinegap=\skip57
407 | \multlinetaggap=\skip58
408 | \mathdisplay@stack=\toks26
409 | LaTeX Info: Redefining \[ on input line 2844.
410 | LaTeX Info: Redefining \] on input line 2845.
411 | )
412 | (resources/joules.aux)
413 | \openout1 = `joules.aux'.
414 |
415 | LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 41.
416 | LaTeX Font Info: ... okay on input line 41.
417 | LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 41.
418 | LaTeX Font Info: ... okay on input line 41.
419 | LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 41.
420 | LaTeX Font Info: ... okay on input line 41.
421 | LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 41.
422 | LaTeX Font Info: ... okay on input line 41.
423 | LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 41.
424 | LaTeX Font Info: ... okay on input line 41.
425 | LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 41.
426 | LaTeX Font Info: ... okay on input line 41.
427 | Now handling font encoding TS1 ...
428 | ... processing UTF-8 mapping file for font encoding TS1
429 |
430 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/ts1enc.dfu
431 | File: ts1enc.dfu 2018/10/05 v1.2f UTF-8 support for inputenc
432 | defining Unicode char U+00A2 (decimal 162)
433 | defining Unicode char U+00A3 (decimal 163)
434 | defining Unicode char U+00A4 (decimal 164)
435 | defining Unicode char U+00A5 (decimal 165)
436 | defining Unicode char U+00A6 (decimal 166)
437 | defining Unicode char U+00A7 (decimal 167)
438 | defining Unicode char U+00A8 (decimal 168)
439 | defining Unicode char U+00A9 (decimal 169)
440 | defining Unicode char U+00AA (decimal 170)
441 | defining Unicode char U+00AC (decimal 172)
442 | defining Unicode char U+00AE (decimal 174)
443 | defining Unicode char U+00AF (decimal 175)
444 | defining Unicode char U+00B0 (decimal 176)
445 | defining Unicode char U+00B1 (decimal 177)
446 | defining Unicode char U+00B2 (decimal 178)
447 | defining Unicode char U+00B3 (decimal 179)
448 | defining Unicode char U+00B4 (decimal 180)
449 | defining Unicode char U+00B5 (decimal 181)
450 | defining Unicode char U+00B6 (decimal 182)
451 | defining Unicode char U+00B7 (decimal 183)
452 | defining Unicode char U+00B9 (decimal 185)
453 | defining Unicode char U+00BA (decimal 186)
454 | defining Unicode char U+00BC (decimal 188)
455 | defining Unicode char U+00BD (decimal 189)
456 | defining Unicode char U+00BE (decimal 190)
457 | defining Unicode char U+00D7 (decimal 215)
458 | defining Unicode char U+00F7 (decimal 247)
459 | defining Unicode char U+0192 (decimal 402)
460 | defining Unicode char U+02C7 (decimal 711)
461 | defining Unicode char U+02D8 (decimal 728)
462 | defining Unicode char U+02DD (decimal 733)
463 | defining Unicode char U+0E3F (decimal 3647)
464 | defining Unicode char U+2016 (decimal 8214)
465 | defining Unicode char U+2020 (decimal 8224)
466 | defining Unicode char U+2021 (decimal 8225)
467 | defining Unicode char U+2022 (decimal 8226)
468 | defining Unicode char U+2030 (decimal 8240)
469 | defining Unicode char U+2031 (decimal 8241)
470 | defining Unicode char U+203B (decimal 8251)
471 | defining Unicode char U+203D (decimal 8253)
472 | defining Unicode char U+2044 (decimal 8260)
473 | defining Unicode char U+204E (decimal 8270)
474 | defining Unicode char U+2052 (decimal 8274)
475 | defining Unicode char U+20A1 (decimal 8353)
476 | defining Unicode char U+20A4 (decimal 8356)
477 | defining Unicode char U+20A6 (decimal 8358)
478 | defining Unicode char U+20A9 (decimal 8361)
479 | defining Unicode char U+20AB (decimal 8363)
480 | defining Unicode char U+20AC (decimal 8364)
481 | defining Unicode char U+20B1 (decimal 8369)
482 | defining Unicode char U+2103 (decimal 8451)
483 | defining Unicode char U+2116 (decimal 8470)
484 | defining Unicode char U+2117 (decimal 8471)
485 | defining Unicode char U+211E (decimal 8478)
486 | defining Unicode char U+2120 (decimal 8480)
487 | defining Unicode char U+2122 (decimal 8482)
488 | defining Unicode char U+2126 (decimal 8486)
489 | defining Unicode char U+2127 (decimal 8487)
490 | defining Unicode char U+212E (decimal 8494)
491 | defining Unicode char U+2190 (decimal 8592)
492 | defining Unicode char U+2191 (decimal 8593)
493 | defining Unicode char U+2192 (decimal 8594)
494 | defining Unicode char U+2193 (decimal 8595)
495 | defining Unicode char U+2329 (decimal 9001)
496 | defining Unicode char U+232A (decimal 9002)
497 | defining Unicode char U+2422 (decimal 9250)
498 | defining Unicode char U+25E6 (decimal 9702)
499 | defining Unicode char U+25EF (decimal 9711)
500 | defining Unicode char U+266A (decimal 9834)
501 | defining Unicode char U+FEFF (decimal 65279)
502 | )
503 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/translator/translator-basic-
504 | dictionary-English.dict
505 | Dictionary: translator-basic-dictionary, Language: English
506 | )
507 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/siunitx/siunitx-abbreviation
508 | s.cfg
509 | File: siunitx-abbreviations.cfg 2017/11/26 v2.7k siunitx: Abbreviated units
510 | ) [1
511 |
512 | ] (resources/joules.aux) )
513 | Here is how much of TeX's memory you used:
514 | 14797 strings out of 494061
515 | 294083 string characters out of 6163061
516 | 307545 words of memory out of 5000000
517 | 18456 multiletter control sequences out of 15000+600000
518 | 534514 words of font info for 33 fonts, out of 8000000 for 9000
519 | 319 hyphenation exceptions out of 8191
520 | 40i,9n,63p,289b,839s stack positions out of 5000i,500n,10000p,200000b,80000s
521 |
522 | Output written on resources/joules.dvi (1 page, 772 bytes).
523 |
--------------------------------------------------------------------------------
/test/resources/joules.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/joules.png
--------------------------------------------------------------------------------
/test/resources/joules.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage[usenames]{color}
3 | \pagestyle{empty} % do not remove
4 | % The settings below are copied from fullpage.sty
5 | \setlength{\textwidth}{\paperwidth}
6 | \addtolength{\textwidth}{-3cm}
7 | \setlength{\oddsidemargin}{1.5cm}
8 | \addtolength{\oddsidemargin}{-2.54cm}
9 | \setlength{\evensidemargin}{\oddsidemargin}
10 | \setlength{\textheight}{\paperheight}
11 | \addtolength{\textheight}{-\headheight}
12 | \addtolength{\textheight}{-\headsep}
13 | \addtolength{\textheight}{-\footskip}
14 | \addtolength{\textheight}{-3cm}
15 | \setlength{\topmargin}{1.5cm}
16 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
17 | \usepackage{xcolor}
18 | %\setlength{\fboxsep}{0pt}
19 | \usepackage{soul}
20 | \usepackage{adjustbox}
21 | \usepackage{siunitx}
22 | \usepackage{amsmath}
23 |
24 | \usepackage{xparse}
25 |
26 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
27 | \begingroup\colorlet{currcolor}{.}%
28 | \IfValueTF{#1}
29 | {\textcolor[#1]{#2}}
30 | {\textcolor{#2}}
31 | {%
32 | #3% the nucleus
33 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
34 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
35 | }%
36 | \endgroup
37 | }
38 |
39 | \newcommand{\cmt}[1]{\ignorespaces}
40 |
41 | \begin{document}
42 | \definecolor{fg}{rgb}{0 0 0}
43 | \definecolor{bg}{rgb}{1 1 1}
44 | \pagecolor{bg}
45 | {\color{fg}
46 | \[ \boxed{\eta = \frac{\SI{6.27e8}{\joule}}{\SI{7.96e9}{\joule}} = 0.0787} \]
47 | }
48 | \end{document}
49 |
--------------------------------------------------------------------------------
/test/resources/pythag.log:
--------------------------------------------------------------------------------
1 | This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex 2019.5.19) 22 OCT 2019 21:20
2 | entering extended mode
3 | restricted \write18 enabled.
4 | %&-line parsing enabled.
5 | **resources/pythag.tex
6 | (./resources/pythag.tex
7 | LaTeX2e <2018-12-01>
8 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/article.cls
9 | Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
10 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/base/size10.clo
11 | File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
12 | )
13 | \c@part=\count80
14 | \c@section=\count81
15 | \c@subsection=\count82
16 | \c@subsubsection=\count83
17 | \c@paragraph=\count84
18 | \c@subparagraph=\count85
19 | \c@figure=\count86
20 | \c@table=\count87
21 | \abovecaptionskip=\skip41
22 | \belowcaptionskip=\skip42
23 | \bibindent=\dimen102
24 | )
25 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/color.sty
26 | Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
27 |
28 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
29 | File: color.cfg 2016/01/02 v1.6 sample color configuration
30 | )
31 | Package color Info: Driver file: dvips.def on input line 147.
32 |
33 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-def/dvips.def
34 | File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
35 | )
36 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/dvipsnam.def
37 | File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
38 | ))
39 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xcolor/xcolor.sty
40 | Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
41 |
42 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/color.cfg
43 | File: color.cfg 2016/01/02 v1.6 sample color configuration
44 | )
45 | Package xcolor Info: Driver file: dvips.def on input line 225.
46 | LaTeX Info: Redefining \color on input line 709.
47 | Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
48 | Package xcolor Info: Model `RGB' extended on input line 1364.
49 | Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
50 | Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
51 | Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
52 | Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
53 | Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
54 | Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
55 | )
56 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/soul/soul.sty
57 | Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
58 | \SOUL@word=\toks14
59 | \SOUL@lasttoken=\toks15
60 | \SOUL@cmds=\toks16
61 | \SOUL@buffer=\toks17
62 | \SOUL@token=\toks18
63 | \SOUL@spaceskip=\skip43
64 | \SOUL@ttwidth=\dimen103
65 | \SOUL@uldp=\dimen104
66 | \SOUL@ulht=\dimen105
67 | )
68 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjustbox.sty
69 | Package: adjustbox 2019/01/04 v1.2 Adjusting TeX boxes (trim, clip, ...)
70 |
71 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/xkeyval/xkeyval.sty
72 | Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
73 |
74 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkeyval.tex
75 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/xkvutils.tex
76 | \XKV@toks=\toks19
77 | \XKV@tempa@toks=\toks20
78 |
79 | (/usr/local/texlive/2019basic/texmf-dist/tex/generic/xkeyval/keyval.tex))
80 | \XKV@depth=\count88
81 | File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
82 | ))
83 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/adjcalc.sty
84 | Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
85 | -ends (calc, etex, pgfmath)
86 | )
87 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/trimclip.sty
88 | Package: trimclip 2018/04/08 v1.1 Trim and clip general TeX material
89 |
90 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphicx.sty
91 | Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
92 |
93 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/graphics.sty
94 | Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
95 |
96 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics/trig.sty
97 | Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
98 | )
99 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
100 | File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
101 | )
102 | Package graphics Info: Driver file: dvips.def on input line 99.
103 | )
104 | \Gin@req@height=\dimen106
105 | \Gin@req@width=\dimen107
106 | ) (/usr/local/texlive/2019basic/texmf-dist/tex/latex/collectbox/collectbox.sty
107 | Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
108 | \collectedbox=\box27
109 | )
110 | \tc@llx=\dimen108
111 | \tc@lly=\dimen109
112 | \tc@urx=\dimen110
113 | \tc@ury=\dimen111
114 | Package trimclip Info: Using driver 'tc-dvips.def'.
115 |
116 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/adjustbox/tc-dvips.def
117 | File: tc-dvips.def 2019/01/04 v2.2 Clipping driver for dvips
118 | ))
119 | \adjbox@Width=\dimen112
120 | \adjbox@Height=\dimen113
121 | \adjbox@Depth=\dimen114
122 | \adjbox@Totalheight=\dimen115
123 | \adjbox@pwidth=\dimen116
124 | \adjbox@pheight=\dimen117
125 | \adjbox@pdepth=\dimen118
126 | \adjbox@ptotalheight=\dimen119
127 | )
128 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
129 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3.sty
130 | Package: expl3 2019-04-06 L3 programming layer (loader)
131 |
132 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/expl3-code.tex
133 | Package: expl3 2019-04-06 L3 programming layer (code)
134 | \c_max_int=\count89
135 | \l_tmpa_int=\count90
136 | \l_tmpb_int=\count91
137 | \g_tmpa_int=\count92
138 | \g_tmpb_int=\count93
139 | \g__kernel_prg_map_int=\count94
140 | \c__ior_term_ior=\count95
141 | \c_log_iow=\count96
142 | \l_iow_line_count_int=\count97
143 | \l__iow_line_target_int=\count98
144 | \l__iow_one_indent_int=\count99
145 | \l__iow_indent_int=\count100
146 | \c_zero_dim=\dimen120
147 | \c_max_dim=\dimen121
148 | \l_tmpa_dim=\dimen122
149 | \l_tmpb_dim=\dimen123
150 | \g_tmpa_dim=\dimen124
151 | \g_tmpb_dim=\dimen125
152 | \c_zero_skip=\skip44
153 | \c_max_skip=\skip45
154 | \l_tmpa_skip=\skip46
155 | \l_tmpb_skip=\skip47
156 | \g_tmpa_skip=\skip48
157 | \g_tmpb_skip=\skip49
158 | \c_zero_muskip=\muskip10
159 | \c_max_muskip=\muskip11
160 | \l_tmpa_muskip=\muskip12
161 | \l_tmpb_muskip=\muskip13
162 | \g_tmpa_muskip=\muskip14
163 | \g_tmpb_muskip=\muskip15
164 | \l_keys_choice_int=\count101
165 | \l__intarray_loop_int=\count102
166 | \c__intarray_sp_dim=\dimen126
167 | \g__intarray_font_int=\count103
168 | \c__fp_leading_shift_int=\count104
169 | \c__fp_middle_shift_int=\count105
170 | \c__fp_trailing_shift_int=\count106
171 | \c__fp_big_leading_shift_int=\count107
172 | \c__fp_big_middle_shift_int=\count108
173 | \c__fp_big_trailing_shift_int=\count109
174 | \c__fp_Bigg_leading_shift_int=\count110
175 | \c__fp_Bigg_middle_shift_int=\count111
176 | \c__fp_Bigg_trailing_shift_int=\count112
177 | \c__kernel_randint_max_int=\count113
178 | \g__fp_array_int=\count114
179 | \l__fp_array_loop_int=\count115
180 | \l__sort_length_int=\count116
181 | \l__sort_min_int=\count117
182 | \l__sort_top_int=\count118
183 | \l__sort_max_int=\count119
184 | \l__sort_true_max_int=\count120
185 | \l__sort_block_int=\count121
186 | \l__sort_begin_int=\count122
187 | \l__sort_end_int=\count123
188 | \l__sort_A_int=\count124
189 | \l__sort_B_int=\count125
190 | \l__sort_C_int=\count126
191 | \l__tl_analysis_normal_int=\count127
192 | \l__tl_analysis_index_int=\count128
193 | \l__tl_analysis_nesting_int=\count129
194 | \l__tl_analysis_type_int=\count130
195 | \l__regex_internal_a_int=\count131
196 | \l__regex_internal_b_int=\count132
197 | \l__regex_internal_c_int=\count133
198 | \l__regex_balance_int=\count134
199 | \l__regex_group_level_int=\count135
200 | \l__regex_mode_int=\count136
201 | \c__regex_cs_in_class_mode_int=\count137
202 | \c__regex_cs_mode_int=\count138
203 | \l__regex_catcodes_int=\count139
204 | \l__regex_default_catcodes_int=\count140
205 | \c__regex_catcode_D_int=\count141
206 | \c__regex_catcode_S_int=\count142
207 | \c__regex_catcode_L_int=\count143
208 | \c__regex_catcode_O_int=\count144
209 | \c__regex_catcode_A_int=\count145
210 | \c__regex_all_catcodes_int=\count146
211 | \l__regex_show_lines_int=\count147
212 | \l__regex_min_state_int=\count148
213 | \l__regex_max_state_int=\count149
214 | \l__regex_left_state_int=\count150
215 | \l__regex_right_state_int=\count151
216 | \l__regex_capturing_group_int=\count152
217 | \l__regex_min_pos_int=\count153
218 | \l__regex_max_pos_int=\count154
219 | \l__regex_curr_pos_int=\count155
220 | \l__regex_start_pos_int=\count156
221 | \l__regex_success_pos_int=\count157
222 | \l__regex_curr_char_int=\count158
223 | \l__regex_curr_catcode_int=\count159
224 | \l__regex_last_char_int=\count160
225 | \l__regex_case_changed_char_int=\count161
226 | \l__regex_curr_state_int=\count162
227 | \l__regex_step_int=\count163
228 | \l__regex_min_active_int=\count164
229 | \l__regex_max_active_int=\count165
230 | \l__regex_replacement_csnames_int=\count166
231 | \l__regex_match_count_int=\count167
232 | \l__regex_min_submatch_int=\count168
233 | \l__regex_submatch_int=\count169
234 | \l__regex_zeroth_submatch_int=\count170
235 | \g__regex_trace_regex_int=\count171
236 | \c_empty_box=\box28
237 | \l_tmpa_box=\box29
238 | \l_tmpb_box=\box30
239 | \g_tmpa_box=\box31
240 | \g_tmpb_box=\box32
241 | \l__box_top_dim=\dimen127
242 | \l__box_bottom_dim=\dimen128
243 | \l__box_left_dim=\dimen129
244 | \l__box_right_dim=\dimen130
245 | \l__box_top_new_dim=\dimen131
246 | \l__box_bottom_new_dim=\dimen132
247 | \l__box_left_new_dim=\dimen133
248 | \l__box_right_new_dim=\dimen134
249 | \l__box_internal_box=\box33
250 | \l__coffin_internal_box=\box34
251 | \l__coffin_internal_dim=\dimen135
252 | \l__coffin_offset_x_dim=\dimen136
253 | \l__coffin_offset_y_dim=\dimen137
254 | \l__coffin_x_dim=\dimen138
255 | \l__coffin_y_dim=\dimen139
256 | \l__coffin_x_prime_dim=\dimen140
257 | \l__coffin_y_prime_dim=\dimen141
258 | \c_empty_coffin=\box35
259 | \l__coffin_aligned_coffin=\box36
260 | \l__coffin_aligned_internal_coffin=\box37
261 | \l_tmpa_coffin=\box38
262 | \l_tmpb_coffin=\box39
263 | \g_tmpa_coffin=\box40
264 | \g_tmpb_coffin=\box41
265 | \l__coffin_bounding_shift_dim=\dimen142
266 | \l__coffin_left_corner_dim=\dimen143
267 | \l__coffin_right_corner_dim=\dimen144
268 | \l__coffin_bottom_corner_dim=\dimen145
269 | \l__coffin_top_corner_dim=\dimen146
270 | \l__coffin_scaled_total_height_dim=\dimen147
271 | \l__coffin_scaled_width_dim=\dimen148
272 | \c__coffin_empty_coffin=\box42
273 | \l__coffin_display_coffin=\box43
274 | \l__coffin_display_coord_coffin=\box44
275 | \l__coffin_display_pole_coffin=\box45
276 | \l__coffin_display_offset_dim=\dimen149
277 | \l__coffin_display_x_dim=\dimen150
278 | \l__coffin_display_y_dim=\dimen151
279 | \g__file_internal_ior=\read1
280 | \l__seq_internal_a_int=\count172
281 | \l__seq_internal_b_int=\count173
282 | \c__deprecation_minus_one=\count174
283 | )
284 | (/usr/local/texlive/2019basic/texmf-dist/tex/latex/l3kernel/l3dvips.def
285 | File: l3dvips.def 2019-04-06 v L3 Experimental driver: dvips
286 | \g__driver_pdf_object_int=\count175
287 | ))
288 | Package: xparse 2019-03-05 L3 Experimental document command parser
289 | \l__xparse_current_arg_int=\count176
290 | \g__xparse_grabber_int=\count177
291 | \l__xparse_m_args_int=\count178
292 | \l__xparse_v_nesting_int=\count179
293 | )
294 | (resources/pythag.aux)
295 | \openout1 = `pythag.aux'.
296 |
297 | LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 53.
298 | LaTeX Font Info: ... okay on input line 53.
299 | LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 53.
300 | LaTeX Font Info: ... okay on input line 53.
301 | LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 53.
302 | LaTeX Font Info: ... okay on input line 53.
303 | LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 53.
304 | LaTeX Font Info: ... okay on input line 53.
305 | LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 53.
306 | LaTeX Font Info: ... okay on input line 53.
307 | LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 53.
308 | LaTeX Font Info: ... okay on input line 53.
309 | LaTeX Font Info: External font `cmex10' loaded for size
310 | (Font) <7> on input line 58.
311 | LaTeX Font Info: External font `cmex10' loaded for size
312 | (Font) <5> on input line 58.
313 | [1
314 |
315 | ] (resources/pythag.aux) )
316 | Here is how much of TeX's memory you used:
317 | 11742 strings out of 494061
318 | 220393 string characters out of 6163061
319 | 243562 words of memory out of 5000000
320 | 15447 multiletter control sequences out of 15000+600000
321 | 532651 words of font info for 25 fonts, out of 8000000 for 9000
322 | 319 hyphenation exceptions out of 8191
323 | 40i,5n,63p,269b,317s stack positions out of 5000i,500n,10000p,200000b,80000s
324 |
325 | Output written on resources/pythag.dvi (1 page, 544 bytes).
326 |
--------------------------------------------------------------------------------
/test/resources/pythag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnbcoughlin/calctex/67a2e76847a9ea9eff1f8e4eb37607f84b380ebb/test/resources/pythag.png
--------------------------------------------------------------------------------
/test/resources/pythag.tex:
--------------------------------------------------------------------------------
1 | % Copyright (C) 2019 John B Coughlin
2 |
3 | % This program is free software: you can redistribute it and/or modify
4 | % it under the terms of the GNU General Public License as published by
5 | % the Free Software Foundation, either version 3 of the License, or
6 | % (at your option) any later version.
7 |
8 | % This program is distributed in the hope that it will be useful,
9 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % GNU General Public License for more details.
12 |
13 | % You should have received a copy of the GNU General Public License
14 | % along with this program. If not, see .
15 |
16 |
17 | \documentclass{article}
18 | \usepackage[usenames]{color}
19 | \pagestyle{empty} % do not remove
20 | % The settings below are copied from fullpage.sty
21 | \setlength{\textwidth}{\paperwidth}
22 | \addtolength{\textwidth}{-3cm}
23 | \setlength{\oddsidemargin}{1.5cm}
24 | \addtolength{\oddsidemargin}{-2.54cm}
25 | \setlength{\evensidemargin}{\oddsidemargin}
26 | \setlength{\textheight}{\paperheight}
27 | \addtolength{\textheight}{-\headheight}
28 | \addtolength{\textheight}{-\headsep}
29 | \addtolength{\textheight}{-\footskip}
30 | \addtolength{\textheight}{-3cm}
31 | \setlength{\topmargin}{1.5cm}
32 | \addtolength{\topmargin}{-2.54cm}% Set up highlighting for simulating the cursor
33 | \usepackage{xcolor}
34 | %\setlength{\fboxsep}{0pt}
35 | \usepackage{soul}
36 | \usepackage{adjustbox}
37 |
38 | \usepackage{xparse}
39 |
40 | \NewDocumentCommand{\colornucleus}{omme{_^}}{%
41 | \begingroup\colorlet{currcolor}{.}%
42 | \IfValueTF{#1}
43 | {\textcolor[#1]{#2}}
44 | {\textcolor{#2}}
45 | {%
46 | #3% the nucleus
47 | \IfValueT{#4}{_{\textcolor{currcolor}{#4}}}% subscript
48 | \IfValueT{#5}{^{\textcolor{currcolor}{#5}}}% superscript
49 | }%
50 | \endgroup
51 | }
52 |
53 | \begin{document}
54 | \definecolor{fg}{rgb}{0 0 0}
55 | \definecolor{bg}{rgb}{1 1 1}
56 | \pagecolor{bg}
57 | {\color{fg}
58 | \[ a^2 + b^2 = c^2 \]
59 | }
60 | \end{document}
--------------------------------------------------------------------------------
/test/resources/test.org:
--------------------------------------------------------------------------------
1 | * Heading 1
2 | ** An equation
3 | \[ \cmt{a^2 + b^2 = c^2} a^2 + b^2 = c^2 \]
4 | ** Another one
5 | $\cmt{exp(i * pi) + 1 = 0} e^{i\pi} + 1 = 0$
6 |
7 | postamble
8 |
9 | $a + b$
10 |
11 | $x + 4y$
12 |
13 | \begin{align*}
14 | \int y ds
15 | \end{align*}
16 |
17 | \begin{equation*}
18 | \sum 4 + x
19 | \end{equation*}
20 |
21 | \begin{equation*}
22 | \prod x + y
23 | \end{equation*}
24 |
25 | \begin{align*}
26 | \int r dr
27 | \end{align*}
28 |
29 | $\mu$
30 |
--------------------------------------------------------------------------------
/test/test-helper.el:
--------------------------------------------------------------------------------
1 | ;;; test-helper.el --- Helpers for calctex-test.el
2 |
3 | (setq debug-on-error t)
4 | (setq debug-on-quit t)
5 |
6 | (set-face-attribute 'default nil :foreground "black" :background "white")
7 |
8 | (defvar calctex-test-resources-dir nil "The directory where test resources live")
9 |
10 | (setq calctex-dvichop-sty "../../vendor/texd/dvichop.sty")
11 | (setq calctex-dvichop-bin "../../vendor/texd/dvichop")
12 |
13 | (setq calctex-test-resources-dir (expand-file-name "resources" (file-name-directory load-file-name)))
14 |
15 | (defun resource-file (name)
16 | (expand-file-name name calctex-test-resources-dir))
17 |
18 | (defun assert-overlay-image-equals (ov reference-image)
19 | (message "%s" reference-image)
20 | (let* ((disp (overlay-get ov 'display))
21 | (actual-file (plist-get (cdr disp) :file)))
22 | (assert-image-equals actual-file reference-image)))
23 |
24 | (defun assert-image-equals (actual expected)
25 | (message "%s" expected)
26 | (message "%s" (resource-file expected))
27 | (let* ((file-comp (format "cmp %s %s" actual (resource-file expected)))
28 | (equality (shell-command file-comp)))
29 | (progn
30 | (message "ran: %s" file-comp)
31 | (should (= equality 0)))))
32 |
33 | ;;; test-helper.el ends here
34 |
--------------------------------------------------------------------------------
/vendor/texd/ANNOUNCE:
--------------------------------------------------------------------------------
1 | [ANN] texd 0.3, texpad 0.1, latexpad 0.1
2 |
3 | texd 0.3 -- runs TeX in daemon mode, much quicker for small files
4 | texpad 0.1 -- interactive evaluation of plain TeX expressions
5 | latexpad 0.1 -- interactive evaluation of LaTeX expressions
6 |
7 | TeX takes a little while to load, but will then typeset pages very
8 | quickly. Interactive applications typically typeset lots of small
9 | items. By running TeX in daemon mode, its start-up time can be
10 | removed from the loop.
11 |
12 | TeXpad and LaTeXpad are interactive applications of the TeX daemon.
13 | The user enters material at a TeX prompt, which is then typeset and
14 | displayed in xdvi. They provide a sort of 'calculator' for (La)TeX.
15 | The response is almost instantaneous.
16 |
17 | The TeX daemon works with existing TeX distributions, and on small
18 | files it is seven times quicker than batch mode. If your version of
19 | TeX has ipc (interprocess communication) enabled, the TeX daemon will
20 | be about 50 times quicker than batch mode.
21 |
22 | Instant Preview is similar to TeXpad, except that the input comes from
23 | an Emacs buffer. It provides a semi-wysiwyg interface to (La)TeX.
24 | Previously, Instant Preview was distributed as part of the texd
25 | package. It has now been unbundled, and a new release is in
26 | preparation.
27 |
28 | This softare, released under the GPL, was developed under GNU/Linux,
29 | and should run on all Unix platforms.
30 |
31 | Thanks to the TeX Users Group (http://www.tug.org) for hosting the
32 | texd mailing list.
33 | http://tug.org/pipermail/texd -- mailing list archives
34 | http://tug.org/mailman/listinfo/texd -- to join mailing list
35 |
36 | To download, and for more information visit:
37 | http://www.activetex.org
38 |
39 | 24 February 2002
40 |
41 |
--------------------------------------------------------------------------------
/vendor/texd/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) year name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/vendor/texd/FAQ:
--------------------------------------------------------------------------------
1 | $Id: FAQ,v 1.3 2002/02/22 21:03:09 jfine Exp $
2 | This is the TeX daemon and Instant Preview FAQ, version 0.3
3 |
4 | If you don't find the answer to your question here, try looking in the
5 | README and INSTALL files.
6 |
7 | We suggest that you review this FAQ, the README and the INSTALL files
8 | before installing or using TeXpad. A look at the shell script
9 | "texpad" wouldn't hurt either.
10 |
11 | Questions and comments concerning this document should be sent to
12 | mailto:jfine@activetex.org
13 | or join the texd mailing list (see question 10).
14 |
15 |
16 | QUESTIONS
17 | =========
18 |
19 | 0) What's happened to Instant Preview? What's TeXpad?
20 |
21 | 1) Why do I get a blank preview screen?
22 |
23 | 2) Sometimes preview is not instant. Why not?
24 |
25 | 3) How do I magnify the preview of my document?
26 |
27 | 4) How do I use my own LaTeX style file with Instant Preview?
28 |
29 | 5) Why are sections, theorems, ... misnumbered?
30 |
31 | 6) Sometimes the Preview doesn't update after a change. Why?
32 |
33 | 7) Sometimes Emacs freezes. What should I do?
34 |
35 | 8) What is Active TeX?
36 |
37 | 9) What are your development plans?
38 |
39 | 10) Is there a mailing list?
40 |
41 |
42 | ANSWERS
43 | =======
44 |
45 | 0) What's happened to Instant Preview? What's TeXpad?
46 |
47 | Some would-be users of Instant Preview found that they couldn't get it
48 | working on their system. So we've broken installation into stages.
49 | First, get the TeX daemon up and running.
50 |
51 | Meanwhile, my understanding as to how to use the TeX daemon in
52 | interactive applications has moved on somewhat. So I'm taking this as
53 | an opportunity to rework the code (and fix some faults in the Emacs
54 | macros).
55 |
56 | Instead, we've bundled TeXpad in with the distribution. It's rather
57 | like the usual command line interface to TeX, except that the material
58 | is typeset, and displayed by xdvi.
59 |
60 | If you really want Instant Preview, download v0.2 of the TeX daemon,
61 | and make appropriate revisions to the scripts there. When you're
62 | done, please send the scripts back to me.
63 |
64 | Most of the other FAQ questions relate to Instant Preview, and I've
65 | left them in this issue of the FAQ.
66 |
67 |
68 | 1) Why do I get a blank preview screen?
69 |
70 | Instant Preview uses xdvi as its previewer. When Instant Preview
71 | starts up, it needs a dvi file. We give it one that contains a single
72 | empty page. This is why you get the blank preview screen.
73 |
74 | When you change the contents of any Emacs buffer for which pv-mode is
75 | enabled, the contents of that buffer will be typeset by TeX, and
76 | displayed in the preview screen. So just insert a space, and delete
77 | it, to refresh the preview screen.
78 |
79 | Sometimes xdvi will die. In this case, we restart xdvi, giving it a
80 | blank preview screen. (It seems that xdvi dies because it doesn't
81 | like have the dvi file changed while it is reading it. Instant
82 | Preview places new requirements on its components.)
83 |
84 |
85 | 2) Sometimes preview is not instant. Why not?
86 |
87 | If the bitmap form of the fonts used by your document do not already
88 | exist, the TeX installation will generate them. This can take a few
89 | seconds. Most likely, you will experience this the first time you use
90 | Instant Preview, and sometime when you do something new.
91 |
92 | By the way, the fonts used in Display LaTeX (the default style for
93 | Instant Preview) are Hermann Zapf's Euler math fonts, and the Concrete
94 | Roman text font designed by Don Knuth to accompany them. These fonts
95 | were designed to be legible in difficult conditions, as well as to be
96 | beautiful. We think they work well as screen fonts.
97 |
98 |
99 | 3) How do I magnify the preview of my document?
100 |
101 | Instant Preview uses the xdvi program already installed on your
102 | computer. You can use it in the normal way. Give xdvi the focus, and
103 | use the mouse to magnify portions of the preview image. By default,
104 | Instant Preview starts xdvi in what is known as expert mode. Type "x"
105 | to toggle expert mode on and off.
106 |
107 | However, remember that xdvi and Emacs are two applications, and
108 | whichever has the focus gets the keystrokes. Forgetting this can be
109 | the cause of much beeping.
110 |
111 | By the way, you can type "q" to exit xdvi. You might want to do this
112 | to free us some screen real estate. Instant Preview will, if it needs
113 | to, restart xdvi. If you "q" xdvi before exiting Emacs, then Emacs
114 | will not warn that xdvi exists as an active processes.
115 |
116 |
117 | 4) How do I use my own LaTeX style file with Instant Preview?
118 |
119 | They should work straight off. But if you change the preamble, you
120 | will need to exit and re-enter pv-mode. This forces a new instance
121 | of the TeX daemon to be created.
122 |
123 |
124 | 5) Why are sections, theorems, ... misnumbered?
125 |
126 | LaTeX is getting confused. It's been designed to deal with the whole
127 | document from beginning to end, in the correct order, and with each
128 | part processed exactly once. Instant Preview sends multiple variants
129 | of the document to LaTeX, one for each keystroke. So it gets
130 | completely the wrong idea as to how many sections and so forth there
131 | are in the document.
132 |
133 | The solution is to set all counters and so forth to the correct values
134 | at the start of each document, or more exactly at the start of any
135 | document fragment that you would like to preview. The \Belay command
136 | provides a hook for doing this.
137 |
138 | By the way, if you are editing two files at the same time, you can
139 | make pv-mode active in both. The preview window will then show the
140 | most recently changed file.
141 |
142 |
143 | 6) Sometimes the Preview doesn't update after a change. Why?
144 |
145 | Instant Preview relies on regular expressions to determine what part
146 | of the document it should preview. If the search fails, instead you
147 | get a message
148 | Unable to preview chunk
149 | in the minibuffer.
150 |
151 | Due to lack of time (and expertise) the regular expressions used are
152 | not quite good enough, particularly at the ends of the document.
153 |
154 | If you have the time and skills, please help out. This is an
155 | important area of development for Instant Preview, and your help would
156 | be much appreciated.
157 |
158 |
159 | 7) Sometimes Emacs freezes. What should I do?
160 |
161 | If your are using Instant Preview, and the corresponding TeX daemon
162 | either freezes or dies, Emacs will freeze. More exactly, it is
163 | writing to a pipe, and that write is blocked.
164 |
165 | The solution is to unfreeze or restart the TeX daemon. Another method
166 | is to copy the pipe to say /dev/null, thereby emptying it.
167 |
168 | There are quite a few things that could be done to make the TeX daemon
169 | more robust.
170 |
171 |
172 | 8) What is Active TeX?
173 |
174 | TeX's usual backslash-and-braces input syntax arises from its use of
175 | category codes. It causes all manner of problems, both for users and
176 | for programmers. This is particularly true for verbatim and other
177 | special processing of content.
178 |
179 | Active TeX solves category code problems once and for all, by making
180 | all characters active all of the time. It also allows the macro
181 | programmer to enforce and input syntax, and to report input errors to
182 | the user, before the get to TeX's internal mechanisms. No more TeX
183 | error messages.
184 |
185 | Instant Preview is semi-wysiwyg TeX. To go the whole way, and allow
186 | the user to edit the document by interacting with the dvi file, the
187 | dvi file must be made richer in content. Specials are the way to do
188 | this. Active TeX was designed to allow this sort of thing to be done.
189 |
190 | Active TeX also supports an enhanced programming environment.
191 |
192 |
193 | 9) What are your development plans?
194 |
195 | Instant Preview is a combination of TeX the program, LaTeX (or some
196 | other macro package), Emacs, xdvi and finally the TeX daemon.
197 |
198 | In the short term, the goal is to improve the TeX daemon. There's
199 | lots of little (and not so little) things that could be done. Porting
200 | to Windows and Macintosh are examples.
201 |
202 | In the medium term, the goal is to improve the interaction with the
203 | other components (LaTeX, Emacs and xdvi) of Instant Preview.
204 |
205 | In the longer term, the goal is to support a variety of non-TeX input
206 | formats, and to provide rich interaction with the previewed dvi file.
207 |
208 | Wherever possible, I'd like to cooperate with existing projects, such
209 | as dvilib, Lyx and TeXmacs. The TeX daemon can be part of any project
210 | that requires quality real-time text formatting.
211 |
212 |
213 | 10) Is there a mailing list?
214 |
215 | YES. Thanks to the TeX Users Group (http://www.tug.org) for hosting
216 | the texd mailing list.
217 |
218 | To view the mailing list archives
219 | http://tug.org/pipermail/texd
220 |
221 | To join the mailing list
222 | http://tug.org/mailman/listinfo/texd
223 |
224 |
225 | % FAQ ends here
226 |
--------------------------------------------------------------------------------
/vendor/texd/INSTALL:
--------------------------------------------------------------------------------
1 | # $Id: INSTALL,v 1.3 2002/02/23 15:25:37 jfine Exp $
2 | # This file describes v0.3 of the TeX daemon
3 |
4 | INSTALLATION OF THE TEX DAEMON
5 | ==============================
6 |
7 | 1. Making the software
8 |
9 | The command
10 | make
11 | will compile the program dvichop.
12 |
13 |
14 | 2. Testing the software
15 |
16 | The command
17 | timetexd
18 | will exercise the TeX daemon, and print some timing results.
19 |
20 | It has been written for GNU/Linux, and may not work on other
21 | UNIX platforms.
22 |
23 |
24 | 3. Using the software
25 |
26 | TeXpad and LaTeXpad are interactive 'calculators' for use with plain
27 | TeX and LaTeX respectively.
28 |
29 | The command
30 | texpad
31 | will start up TeXpad. Type TeX commands in at the "Gimme:" prompt,
32 | and the result in the xdvi window. Give an empty response to quit.
33 | LaTeXpad is used in the same way.
34 |
35 |
36 | 4. Installing the software
37 |
38 | Files have to be placed where the system can find them. The
39 | most important files are
40 | dvichop -- this should be placed somewhere in your path
41 | dvichop.sty -- this should be placed where (La)TeX can find it
42 |
43 | The other files, "timetexd", "texpad" and "latexpad" are shell
44 | scripts. Please modify them to suit your own needs. They typeset
45 | "texpad.help" and "latexpad.help" do display help in xdvi.
46 |
47 |
48 | 5. Obtaining an ipc enabled TeX (optional)
49 |
50 | On small files, such as Don Knuth's "story.tex", TeX in daemon mode is
51 | about seven times quicker than the usual batch mode.
52 |
53 | But we can do much better than this. Lot's of time is wasted in
54 | flushing TeX's output dvi buffer. When this is eliminated a speed up
55 | of 50 times compared to batch mode is possible.
56 |
57 | For this, you will need a version of TeX that has interprocess
58 | communication (ipc) enabled. Actually, what we need is a TeX that
59 | does not buffer the output dvi stream, and ipc is a pre-existing way
60 | of getting that.
61 |
62 | To discover if your version of TeX has ipc enabled, type
63 | tex --help
64 | and if
65 | -ipc send DVI output to a socket [...]
66 | appears then you have ipc.
67 |
68 | If you have ipc enabled, excellent. (But at time of writing, this is
69 | unlikely.)
70 |
71 | The alternative is to build your own. You have to rebuild TeX from
72 | source, taking care to pass
73 | --enable-ipc
74 | as a parameter to the build process.
75 |
76 | Once you have an ipc enabled TeX, you should remove the flushing from
77 | "dvichop.sty", and supply "-ipc" to TeX's command line.
78 |
79 | The "texpad" and "latexpad" scripts do this automatically.
80 |
81 | # INSTALL ends here
82 |
--------------------------------------------------------------------------------
/vendor/texd/Makefile:
--------------------------------------------------------------------------------
1 | # $Id: Makefile,v 1.3 2002/02/22 20:50:22 jfine Exp $
2 | # Makefile for texd-0.3
3 |
4 | # This program is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU General Public License; either
6 | # version 2 of the License, or (at your option) any later version.
7 |
8 | # For more information about this program, send a message to
9 | # mailto:jfine@activetex.org
10 |
11 | # TO DO
12 | # This Makefile is known to work only for Linux.
13 |
14 | # $Log: Makefile,v $
15 | # Revision 1.3 2002/02/22 20:50:22 jfine
16 | # Revised for version 0.2 of the package
17 | #
18 | # Revision 1.2 2001/10/14 15:08:14 jfine
19 | # Revised for version 0.2 of the package
20 | #
21 |
22 | SHELL=/bin/sh
23 |
24 | dvichop: dvichop.c dviop.h
25 | gcc -Wall dvichop.c -o dvichop
26 |
27 | ## Makefile ends here
28 |
--------------------------------------------------------------------------------
/vendor/texd/README:
--------------------------------------------------------------------------------
1 | # $Id: README,v 1.2 2002/02/23 15:19:23 jfine Exp $
2 | # This file is for release 0.3 of texd
3 |
4 |
5 | THE TEX DAEMON AND TEXPAD
6 | =========================
7 | This bundle has two major parts.
8 |
9 | The first is texd, the TeX daemon. Applied to small files, texd can
10 | be many times quicker than the regular way of using TeX.
11 |
12 | The second is TeXpad and LaTeXpad, which are interactive 'calculators'
13 | for evaluating small pieces of TeX code.
14 |
15 | For news and updates, visit the Active TeX website
16 | http://www.activetex.org
17 |
18 |
19 | THE TEX DAEMON
20 | ==============
21 | TeX is an efficient typesetting program, but it takes a while to get
22 | going. On my machine, which is a 225MHz Cyrix, it takes a full
23 | quarter second to load, but then it can process a simple page in 5
24 | thousands of a second. In other words, the ratio is about 50 to 1.
25 |
26 | The commands
27 | $ time tex \\end
28 | $ time tex story \\end
29 | will tell the story for your machine.
30 |
31 | The TeX daemon allows us to avoid this start-up overhead.
32 |
33 |
34 | DVICHOP
35 | =======
36 | This is a new program, written specifically to enable the TeX daemon.
37 |
38 | The dvichop program takes as input a stream of dvi pages. Its output
39 | is a sequence of usually small dvi files. Marker pages in the input
40 | stream control the division into output dvi files.
41 |
42 |
43 | IPCTEX
44 | ======
45 |
46 | Most implementations of TeX, for reasons of efficiency, buffer their
47 | output dvi stream. This forces the TeX daemon to write empty pages,
48 | to flush out the current page. This is inefficient.
49 |
50 | To get the best out the the TeX daemon, you will need a version of TeX
51 | that disables this system dependant feature. For example, in the
52 | web2c version, build with --enable-ipc and call with command line
53 | switch -ipc.
54 |
55 |
56 | HISTORY OF IPCTEX
57 | =================
58 | Tom Rokicki's implementation of TeX for the NeXT computer contained an
59 | important innovation. It allowed the previewer to start previewing
60 | the dvi file, before TeX had finished producing it. To support this,
61 | it allowed output to be written to a socket. It also suppressed the
62 | output buffering.
63 |
64 | Essentially, ipctex is Tom Rokicki's TeX for NeXT.
65 |
66 |
67 | INSTANT PREVIEW
68 | ===============
69 | Previously, Instant Preview was part of the "texd" package. From
70 | now on, it will be distributed separately.
71 |
72 | Instant Preview is being rewritten, to use the interface to the TeX
73 | daemon exposed by the new file "dvichop.sty".
74 |
75 |
76 | REQUIREMENTS
77 | ============
78 |
79 | This software has been developed on Linux. It should run on Unix
80 | platforms, but this has not been tested.
81 |
82 | See the separate file INSTALL for installation notes.
83 |
84 | # README ends here
85 |
--------------------------------------------------------------------------------
/vendor/texd/dvichop.sty:
--------------------------------------------------------------------------------
1 | % $Id: dvichop.sty,v 1.1 2002/02/22 20:36:59 jfine Exp $
2 | % TeX macros providing an interface to dvichop
3 |
4 | % Copyright (c) Jonathan Fine, 2001
5 | % mailto:jfine@activetex.org
6 |
7 | % This program is free software; you can redistribute it and/or modify
8 | % it under the terms of the GNU General Public License; either version
9 | % 2 of the License, or (at your option) any later version.
10 |
11 | % $Log: dvichop.sty,v $
12 | % Revision 1.1 2002/02/22 20:36:59 jfine
13 | % Initial revision
14 | %
15 |
16 | % Take care of LaTeX/LaTeX2e bookkeeping.
17 | \ifx \documentstyle \undefined \else
18 | \ifx \documentclass \undefined
19 | \else \ProvidesPackage{dvichop}[2002/03/02] \fi
20 | \fi
21 |
22 | \global\mathchardef\DviNum 0 % write file \number\DviNum.dvi
23 | \global\mathchardef\DviPid 0 % if non-zero send SIGUSR1 to the process
24 | \chardef\DviVer 99 % interface version number (99 means not yet stable)
25 |
26 | \def\DviMark #1#2#3% write a marker page
27 | {%
28 | \begingroup
29 | \count0 \maxdimen % key value
30 | \count1 #1% operation
31 | \count2 #2% operand
32 | \count3 #3% operand
33 | \count4 0 \count5 0 \count6 0
34 | \count7 0 \count8 0 \count9 0
35 | \shipout\hbox{}%
36 | \endgroup
37 | }
38 |
39 | \def\DviOpen {\DviMark 1\DviVer0} % say "Hello" to dvichop
40 | \def\DviClose {\DviMark 200} % say "Goodbye" to dvichop
41 | \def\DviBegin {\DviMark 300} % write following to dvi file ...
42 | \def\DviEnd {\DviMark 4\DviNum\DviPid\DviFlush} % ... up to here
43 |
44 | \newbox\DviFlushBox % just big enough to be sure to flush |dvi_buf|
45 | \setbox\DviFlushBox\hbox{%
46 | \count0 8192 % half of |dvi_buf_size|
47 | \multiply\count0 2 % now |dvi_buf_size|
48 | \advance\count0 -51 % overhead (bop=45, special=5, eop=1)
49 | \multiply\count0 1000 % who did I learn this from?
50 | \special{\romannumeral \count0}} % just big enough to flush
51 |
52 | \def\DviFlush {%
53 | \DviBegin
54 | \shipout\copy\DviFlushBox
55 | \DviMark 400% \DviEnd, writes file "0.dvi", no signal
56 | }
57 |
58 | \let\DviFlush\relax %% uncomment only if you're running "tex --ipc"
59 |
60 | % end of dvichop.sty
61 |
--------------------------------------------------------------------------------
/vendor/texd/dviop.h:
--------------------------------------------------------------------------------
1 | /* $Id: dviop.h,v 1.1 2001/05/27 19:53:07 jfine Exp $ */
2 | /* -*- linux-c -*- */
3 | /*
4 | email:jfine@active-tex.demon.co.uk
5 |
6 | Maybe this should be called dviopc.h. But most of the dviopc are in
7 | fact dviops: they have no operand
8 |
9 | $Log: dviop.h,v $
10 | Revision 1.1 2001/05/27 19:53:07 jfine
11 | Initial revision
12 |
13 |
14 | */
15 |
16 | /*
17 |
18 | A dvi file consists of a sequence of dvi operations. A dvi operation
19 | consists of a code followed by an operand, which may be empty. Some
20 | operations have a string of some sort as part of its operand. The
21 | length of such operations is variable.
22 |
23 | This file, following Don Knuth's example in dvitype, provides symbolic
24 | names for the dvi opcodes. The names are exactly as given by Don,
25 | except that "dviop_" has been added as a prefix. Thus, "dviop_bop" is
26 | the begin page operation. This gives us a good chance of avoiding
27 | name clashes with other source files.
28 |
29 | A trick allows the programmer to write
30 | case dviop_set_char:
31 | in a switch statement, and by so doing catch dviop_set_char_1 through
32 | to dviop_set_char_127. Don's "sixty_four_cases()" macro is a similar
33 | trick.
34 |
35 | The 256 dvi operations are divided into classes in various ways. Here
36 | is the division according to size.
37 | switch (op) {
38 | case dviop_misc:
39 | case dviop_set_char:
40 | case dviop_fnt_num:
41 | case dviop_size1:
42 | case dviop_size2:
43 | case dviop_size3:
44 | case dviop_size4:
45 | case dviop_size5:
46 | case dviop_size9:
47 | case dviop_var_size:
48 | case dviop_undefined:
49 | default:
50 | }
51 |
52 | Some comments. 1) The categories misc, set_char and fnt_num are used
53 | in every division. 2) Misc consists of the dvi operations bop, eop,
54 | post and post_post. The cannot appear within a page. 3) Not every
55 | byte-code is a dvi operation. Those that are not are undefined.
56 |
57 | */
58 |
59 | #ifndef _DVI_OP_H
60 | #define _DVI_OP_H
61 |
62 | /* symbolic names for the dvi operations */
63 | enum {
64 | dviop_set_char_0 = 0,
65 | dviop_set1 = 128, dviop_set2, dviop_set3, dviop_set4,
66 | dviop_set_rule,
67 | dviop_put1, dviop_put2, dviop_put3, dviop_put4,
68 | dviop_put_rule, dviop_nop, dviop_bop, dviop_eop,
69 | dviop_push, dviop_pop,
70 | dviop_right1, dviop_right2, dviop_right3, dviop_right4,
71 | dviop_w0, dviop_w1, dviop_w2, dviop_w3, dviop_w4,
72 | dviop_x0, dviop_x1, dviop_x2, dviop_x3, dviop_x4,
73 | dviop_down1, dviop_down2, dviop_down3, dviop_down4,
74 | dviop_y0, dviop_y1, dviop_y2, dviop_y3, dviop_y4,
75 | dviop_z0, dviop_z1, dviop_z2, dviop_z3, dviop_z4,
76 | dviop_fnt_num_0,
77 | dviop_fnt1 = 235, dviop_fnt2, dviop_fnt3, dviop_fnt4,
78 | dviop_xxx1, dviop_xxx2, dviop_xxx3, dviop_xxx4,
79 | dviop_fnt_def1, dviop_fnt_def2, dviop_fnt_def3, dviop_fnt_def4,
80 | dviop_pre, dviop_post, dviop_post_post
81 | };
82 |
83 | /* operations that cannot appear within a page */
84 | #define dviop_misc \
85 | dviop_pre: case dviop_bop: case dviop_eop: \
86 | case dviop_post: case dviop_post_post
87 |
88 | /* set a single character, in the current font */
89 | #define dviop_set_char \
90 | 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \
91 | case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: \
92 | case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: \
93 | case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: \
94 | case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: \
95 | case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: \
96 | case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: \
97 | case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: \
98 | case 64: case 65: case 66: case 67: case 68: case 69: case 70: case 71: \
99 | case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: \
100 | case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: \
101 | case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: \
102 | case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: \
103 | case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: \
104 | case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: \
105 | case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127
106 |
107 | /* change the current font */
108 | #define dviop_fnt_num \
109 | 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: \
110 | case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: \
111 | case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: \
112 | case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: \
113 | case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: \
114 | case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: \
115 | case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: \
116 | case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234
117 |
118 | /* operand is empty */
119 | #define dviop_size1 \
120 | dviop_nop: case dviop_push: case dviop_pop: \
121 | case dviop_w0: case dviop_x0: case dviop_y0: case dviop_z0
122 |
123 | /* operand is a single byte */
124 | #define dviop_size2 \
125 | dviop_set1: case dviop_put1: case dviop_right1: case dviop_down1: \
126 | case dviop_w1: case dviop_x1: case dviop_y1: case dviop_z1: \
127 | case dviop_fnt1
128 |
129 | /* operand is two bytes */
130 | #define dviop_size3 \
131 | dviop_set2: case dviop_put2: case dviop_right2: case dviop_down2: \
132 | case dviop_w2: case dviop_x2: case dviop_y2: case dviop_z2: \
133 | case dviop_fnt2
134 |
135 | /* operand is three bytes */
136 | #define dviop_size4 \
137 | dviop_set3: case dviop_put3: case dviop_right3: case dviop_down3: \
138 | case dviop_w3: case dviop_x3: case dviop_y3: case dviop_z3: \
139 | case dviop_fnt3
140 |
141 | /* operand is four bytes, i.e. a quad */
142 | #define dviop_size5 \
143 | dviop_set4: case dviop_put4: case dviop_right4: case dviop_down4: \
144 | case dviop_w4: case dviop_x4: case dviop_y4: case dviop_z4: \
145 | case dviop_fnt4
146 |
147 | /* operand is two quads */
148 | #define dviop_size9 \
149 | dviop_set_rule: case dviop_put_rule
150 |
151 | /* operand's size is variable */
152 | #define dviop_var_size \
153 | dviop_xxx1: case dviop_xxx2: case dviop_xxx3: case dviop_xxx4: \
154 | case dviop_fnt_def1: case dviop_fnt_def2: case dviop_fnt_def3: case dviop_fnt_def4
155 |
156 | /* undefined operations */
157 | #define dviop_undefined \
158 | 250: case 251: case 252: case 253: case 254: case 255
159 |
160 | #endif /* _DVI_DVIOP_H */
161 |
--------------------------------------------------------------------------------
/vendor/texmathp/texmathp.el:
--------------------------------------------------------------------------------
1 | ;;; texmathp.el --- Code to check if point is inside LaTeX math environment
2 |
3 | ;; Copyright (c) 2003 Free Software Foundation, Inc.
4 |
5 | ;; Author: Carsten Dominik
6 | ;; Keywords: tex
7 |
8 | ;; This file is part of GNU Emacs.
9 |
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify
11 | ;; it under the terms of the GNU General Public License as published by
12 | ;; the Free Software Foundation; either version 2, or (at your option)
13 | ;; any later version.
14 |
15 | ;; GNU Emacs is distributed in the hope that it will be useful,
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | ;; GNU General Public License for more details.
19 |
20 | ;; You should have received a copy of the GNU General Public License
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 | ;; Boston, MA 02111-1307, USA.
24 |
25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 | ;;
27 | ;;; Commentary:
28 | ;;
29 | ;; NOTE: This has been vendored from
30 | ;; https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/texmathp.el
31 | ;;
32 | ;; This code provides a function to determine if point in a buffer is
33 | ;; inside a (La)TeX math environment. This is not trivial since many
34 | ;; different ways are used to switch between the two, for example:
35 | ;;
36 | ;; \begin{equation} ... \end{equation}
37 | ;; $ ... $
38 | ;; $$ ... $$
39 | ;; \[ ... \]
40 | ;; \ensuremath{...}
41 | ;; \mbox{...}
42 | ;;
43 | ;; To install, put this file on your load-path and compile it.
44 | ;;
45 | ;; To use this in your lisp program, do
46 | ;;
47 | ;; (require 'texmathp)
48 | ;;
49 | ;; You can then write code like this:
50 | ;;
51 | ;; (if (texmathp) ...)
52 | ;;
53 | ;; The call to `texmathp' leaves some extra information in the
54 | ;; variable `texmathp-why'. It's value is a cons cell (MATCH . POSITION),
55 | ;; specifying which command at what position is responsible for math
56 | ;; mode being on or off.
57 | ;;
58 | ;; To configure which macros and environments influence LaTeX math mode,
59 | ;; customize the variable `texmathp-tex-commands'. By default
60 | ;; it recognizes the LaTeX core as well as AMS-LaTeX (see the variable
61 | ;; `texmathp-tex-commands-default', also as an example).
62 | ;;
63 | ;; To try out the code interactively, use `M-x texmathp RET'.
64 | ;;
65 | ;;--------------------------------------------------------------------------
66 | ;;
67 | ;; LIMITATIONS:
68 | ;;
69 | ;; Of course, in order to work this function has to assume that the
70 | ;; LaTeX above point is syntactically correct. In particular:
71 | ;;
72 | ;; o The different math delimiters are paired correctly. Thus if
73 | ;; you do things like "\begin{equation} $" or "\[ ... \)"
74 | ;; the result of (texmathp) is undefined. It is in fact possible
75 | ;; in LaTeX to pair \[ with $$ and \( with $, but this will confuse
76 | ;; texmathp (and human readers as well).
77 | ;;
78 | ;; o However, texmathp will correctly work with nested delimiters,
79 | ;; e.g. something like this will be parsed correctly at any point:
80 | ;;
81 | ;; \begin{equation}
82 | ;; x = y \mbox{abc \ensuremath{\alpha} cba $2^3$}
83 | ;; \end{equation}
84 | ;;
85 | ;; o texmathp is somewhat forgiving if you have an empty line inside
86 | ;; the current math environment, which is not legal in TeX but may
87 | ;; easily happen during editing. Depending upon the variable
88 | ;; `texmathp-search-n-paragraphs' we check several paragraphs,
89 | ;; backwards, by default 2. Paragraph here means something limited
90 | ;; by an empty line.
91 | ;;
92 | ;; Macros which set or cancel math mode for their arguments are
93 | ;; assumed to do this only for madatory arguments. Optional
94 | ;; arguments are ignored - the mode in these arguments is just like
95 | ;; what is was before the macro.
96 | ;;--------------------------------------------------------------------------
97 |
98 | ;;; Code:
99 |
100 | (defgroup texmathp nil
101 | "Testing TeX and LaTeX documents for math mode."
102 | :tag "Test For TeX and LaTeX Math Mode"
103 | :prefix "texmathp-"
104 | :group 'tex)
105 |
106 | (defcustom texmathp-tex-commands nil
107 | "List of environments and macros influencing (La)TeX math mode.
108 | This user-defined list is used in additions to LaTeX and AMSLaTeX defaults.
109 | The structure of each entry is (NAME TYPE)
110 |
111 | - The first item in each entry is the name of an environment or macro.
112 | If it's a macro, include the backslash.
113 |
114 | - The second item is a symbol indicating how the command works:
115 | `env-on' Environment, turns math mode for its body on
116 | `env-off' Environment: turns math mode for its body off
117 | `arg-on' Command: turns math mode for its arguments on
118 | `arg-off' Command: turns math mode for its arguments off
119 | `sw-on' Switch: turns math-mode of following text on
120 | `sw-off' Switch: turns math-mode of following text off
121 | `sw-toggle' Switch: toggles math mode of following text"
122 | :group 'texmathp
123 | :type
124 | '(repeat
125 | (list :value ("" env-on)
126 | (string :tag "Name")
127 | (choice :tag "Type"
128 | (const :tag "Environment: turns math mode for its body on" env-on)
129 | (const :tag "Environment: turns math mode for its body off" env-off)
130 | (const :tag "Command: turns math mode for its argument on" arg-on)
131 | (const :tag "Command: turns math-mode for its argument off" arg-off)
132 | (const :tag "Switch: turns math-mode of following text on" sw-on)
133 | (const :tag "Switch: turns math-mode of following text off" sw-off)
134 | (const :tag "Switch: toggles math mode of following text" sw-toggle)))))
135 |
136 | (defconst texmathp-tex-commands-default
137 | '(;; Standard LaTeX
138 | ("equation" env-on)
139 | ("eqnarray" env-on) ("eqnarray*" env-on)
140 | ("displaymath" env-on)
141 | ("\\mbox" arg-off)
142 | ("\\(" sw-on) ("\\)" sw-off)
143 | ("\\[" sw-on) ("\\]" sw-off)
144 | ("$$" sw-toggle) ("$" sw-toggle)
145 | ;; AMS-LaTeX
146 | ("equation*" env-on)
147 | ("align" env-on) ("align*" env-on)
148 | ("gather" env-on) ("gather*" env-on)
149 | ("multline" env-on) ("multline*" env-on)
150 | ("flalign" env-on) ("flalign*" env-on)
151 | ("alignat" env-on) ("alignat*" env-on)
152 | ("xalignat" env-on) ("xalignat*" env-on)
153 | ("xxalignat" env-on) ("xxalignat*" env-on)
154 | ("\\ensuremath" arg-on)
155 | ("\\text" arg-off) ("\\intertext" arg-off))
156 | "The default entries for `texmathp-tex-commands', which see.")
157 |
158 | (defcustom texmathp-search-n-paragraphs 2
159 | "*Number of paragraphs to check before point.
160 | Normally, you cannot have an empty line in a math environment in (La)TeX.
161 | Therefore, the fastest method to test for math mode is limiting the
162 | search backward to the nearest empty line.
163 | However, during editing it happens that such lines exist temporarily.
164 | Therefore we look a little further. This variable determines how many
165 | empty lines we go back to fix the search limit."
166 | :group 'texmathp
167 | :type 'number)
168 |
169 | (defcustom texmathp-allow-detached-args nil
170 | "*Non-nil means, allow arguments of macros to be detached by whitespace.
171 | When this is t, `aaa' will be considered as argument of \bb in the following
172 | construct: \bbb [xxx] {aaa}
173 | The disadvantage is that any number of braces expressions will be considered
174 | arguments of the macro independent of its definition."
175 | :group 'texmathp
176 | :type 'boolean)
177 |
178 | (defvar texmathp-why nil
179 | "After a call to `texmathp' this variable shows why math-mode is on or off.
180 | The value is a cons cell (MATCH . POSITION).
181 | MATCH is a string like a car of an entry in `texmathp-tex-commands', e.q.
182 | \"equation\" or \"\\ensuremath\" or \"\\[\" or \"$\".
183 | POSITION is the buffer position of the match. If there was no match,
184 | it points to the limit used for searches, usually two paragraphs up.")
185 |
186 | (defvar texmathp-environments nil)
187 | (defvar texmathp-macros nil)
188 | (defvar texmathp-onoff-regexp nil)
189 | (defvar texmathp-toggle-regexp nil)
190 | (defvar texmathp-tex-commands1 nil)
191 | (defvar texmathp-memory nil)
192 |
193 | ;; We need our own syntax table to play with the syntax of () [] and {}
194 | ;; For speed reasons we define it statically instead of copying it each time.
195 | (defvar texmathp-syntax-table (make-syntax-table)
196 | "Syntax table used while texmathp is parsing.")
197 | (mapcar
198 | (lambda (x) (modify-syntax-entry (car x) (cdr x) texmathp-syntax-table))
199 | '((?\\ . "\\") (?\f .">") (?\n . ">") (?% . "<")
200 | (?\[ . ".") (?\] . ".") (?\{ . "(}") (?\} . "){")
201 | (?\( . ".") (?\) . ".") (?\" . ".") (?& . ".") (?_ . ".")
202 | (?@ . "_") (?~ . " ") (?$ . "$") (?' . "w")))
203 |
204 | (defun texmathp-compile ()
205 | "Compile the value of `texmathp-tex-commands' into the internal lists."
206 |
207 | ;; Extract lists and regexp.
208 | (setq texmathp-macros nil texmathp-environments nil)
209 | (setq texmathp-memory
210 | (cons texmathp-tex-commands texmathp-tex-commands-default))
211 | (setq texmathp-tex-commands1 (append texmathp-tex-commands
212 | texmathp-tex-commands-default))
213 | (let ((list (reverse texmathp-tex-commands1))
214 | var entry type switches togglers)
215 | (while (setq entry (car list))
216 | (setq type (nth 1 entry)
217 | list (cdr list)
218 | var (cond ((memq type '(env-on env-off)) 'texmathp-environments)
219 | ((memq type '(arg-on arg-off)) 'texmathp-macros)
220 | ((memq type '(sw-on sw-off)) 'switches)
221 | ((memq type '(sw-toggle)) 'togglers)))
222 | (set var (cons (car entry) (symbol-value var))))
223 | (setq texmathp-onoff-regexp
224 | (concat "[^\\\\]\\("
225 | (mapconcat 'regexp-quote switches "\\|")
226 | "\\)")
227 | texmathp-toggle-regexp
228 | (concat "\\([^\\\\\\$]\\|\\`\\)\\("
229 | (mapconcat 'regexp-quote togglers "\\|")
230 | "\\)"))))
231 |
232 | (defun texmathp ()
233 | "Determine if point is inside (La)TeX math mode.
234 | Returns t or nil. Additional info is placed into `texmathp-why'.
235 | The functions assumes that you have (almost) syntactically correct (La)TeX in
236 | the buffer.
237 | See the variable `texmathp-tex-commands' about which commands are checked."
238 | (interactive)
239 | (unless (and (eq (car texmathp-memory) texmathp-tex-commands)
240 | (eq (cdr texmathp-memory) texmathp-tex-commands-default))
241 | (texmathp-compile))
242 | (let* ((pos (point)) math-on sw-match
243 | (bound (save-excursion
244 | (if (re-search-backward "[\n\t][ \t]*[\n\r]"
245 | nil 1 texmathp-search-n-paragraphs)
246 | (match-beginning 0)
247 | (point-min))))
248 | (env-match (texmathp-match-environment bound))
249 | (mac-match (texmathp-match-macro bound))
250 | (match (cons nil bound)))
251 |
252 | ;; Select the nearer match
253 | (and env-match (setq match env-match))
254 | (and mac-match (> (cdr mac-match) (cdr match)) (setq match mac-match))
255 | (setq math-on (memq (nth 1 (assoc (car match) texmathp-tex-commands1))
256 | '(env-on arg-on)))
257 |
258 | ;; Check for switches
259 | (and (not math-on)
260 | (setq sw-match (texmathp-match-switch bound))
261 | (> (cdr sw-match) (cdr match))
262 | (eq (nth 1 (assoc (car sw-match) texmathp-tex-commands1)) 'sw-on)
263 | (setq match sw-match math-on t))
264 |
265 | ;; Check for togglers
266 | (if (not math-on)
267 | (save-excursion
268 | (goto-char (cdr match))
269 | (while (re-search-forward texmathp-toggle-regexp pos t)
270 | (if (setq math-on (not math-on))
271 | (setq sw-match (cons (match-string 2) (match-beginning 2)))
272 | (setq sw-match nil)))
273 | (and math-on sw-match (setq match sw-match))))
274 |
275 | ;; Store info, show as message when interactive, and return
276 | (setq texmathp-why match)
277 | (and (interactive-p)
278 | (message "math-mode is %s: %s begins at buffer position %d"
279 | (if math-on "on" "off")
280 | (or (car match) "new paragraph") (cdr match)))
281 | (and math-on t)))
282 |
283 | (defun texmathp-match-macro (bound)
284 | ;; Find out if point is within the arguments of any of the Math macros.
285 | ;; Limit searches to BOUND. The return value is like ("\\macro" . (point)).
286 | (catch 'exit
287 | (and (null texmathp-macros) (throw 'exit nil))
288 | (let (pos cmd (syntax-table (syntax-table)))
289 | (unwind-protect
290 | (save-restriction
291 | (save-excursion
292 | (set-syntax-table texmathp-syntax-table)
293 | (narrow-to-region (max 1 bound) (point))
294 | ;; Move back out of the current parenthesis
295 | (while (progn
296 | ;; Move up out of {}
297 | (modify-syntax-entry ?\{ "(}")
298 | (modify-syntax-entry ?\{ "){")
299 | (modify-syntax-entry ?\[ ".")
300 | (modify-syntax-entry ?\] ".")
301 | (condition-case nil (progn (up-list -1) t) (error nil)))
302 | ;; Move back over touching sexps (in fact also non-touching)
303 | (while
304 | (and
305 | (cond
306 | ((memq (preceding-char) '(?\] ?\})))
307 | ((and
308 | texmathp-allow-detached-args
309 | (re-search-backward
310 | "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\="
311 | bound t))
312 | (goto-char (1+ (match-beginning 0))) t))
313 | (progn
314 | (if (eq (preceding-char) ?\})
315 | (progn
316 | ;; skip {}
317 | (modify-syntax-entry ?\{ "(}")
318 | (modify-syntax-entry ?\} "){")
319 | (modify-syntax-entry ?\[ ".")
320 | (modify-syntax-entry ?\] "."))
321 | ;; skip []
322 | (modify-syntax-entry ?\{ ".")
323 | (modify-syntax-entry ?\} ".")
324 | (modify-syntax-entry ?\[ "(]")
325 | (modify-syntax-entry ?\] ")["))
326 | (condition-case nil
327 | (progn (backward-sexp) t) (error nil)))))
328 | (setq pos (point))
329 | (and (memq (following-char) '(?\[ ?\{))
330 | (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)
331 | (setq cmd (buffer-substring-no-properties
332 | (match-beginning 0) (match-end 0)))
333 | (member cmd texmathp-macros)
334 | (throw 'exit (cons cmd (point))))
335 | (goto-char pos))
336 | (throw 'exit nil)))
337 | (set-syntax-table syntax-table)))))
338 |
339 | (defun texmathp-match-environment (bound)
340 | ;; Find out if point is inside any of the math environments.
341 | ;; Limit searched to BOUND. The return value is like ("equation" . (point)).
342 | (catch 'exit
343 | (save-excursion
344 | (and (null texmathp-environments) (throw 'exit nil))
345 | (let (end-list env)
346 | (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
347 | bound t)
348 | (setq env (buffer-substring-no-properties
349 | (match-beginning 2) (match-end 2)))
350 | (cond ((string= (match-string 1) "end")
351 | (add-to-list 'end-list env))
352 | ((equal env (car end-list))
353 | (setq end-list (cdr end-list)))
354 | ((member env texmathp-environments)
355 | (throw 'exit (cons env (point))))))
356 | nil))))
357 |
358 | (defun texmathp-match-switch (bound)
359 | ;; Search backward for any of the math switches.
360 | ;; Limit searched to BOUND. The return value is like ("\\(" . (point)).
361 | (save-excursion
362 | (if (re-search-backward texmathp-onoff-regexp bound t)
363 | (cons (buffer-substring-no-properties
364 | (match-beginning 1) (match-end 1))
365 | (match-beginning 1))
366 | nil)))
367 |
368 | (provide 'texmathp)
369 |
370 | ;;; texmathp.el ends here
371 |
--------------------------------------------------------------------------------