On 7/12/07, Ryan Krauss <ryanlists at gmail.com> wrote:
> I really two aspects of Robert's proposal:
> 1. being able to customized TEX-ENVIRONMENT so I could set mine to
> \begin{equation}...\end{equation}
> 2. I really like the idea of being able to output comments that don't
> get put in an environment - I like to add comments to any derivation
> or symbolic work so that I can make sense of it later or copy and
> paste it into a publication.
OK, I've made some modifications to src/mactex.lisp (not
yet committed) to change the TeX environment.
Now the following outputs are obtained.
load (stringproc); /* need some stuff for these examples */
(1) Change environment for general expressions to \begin{equation} ...
\end{equation}
get_tex_environment_default ();
=> [$$, $$]
tex (sin(x) + cos(y));
=> $$\cos y+\sin x$$
set_tex_environment_default
(concat (newline, "\\begin{equation}", newline),
concat (newline, "\\end{equation}", newline));
tex (sin(x) + cos(y));
=>
\begin{equation}
\cos y+\sin x
\end{equation}
(2) Change environment for functions from verbatim to equation
get_tex_environment (":=");
=> [$$, $$]
tex (foo(x) := sin(x)^3);
=>
\begin{verbatim}
foo(x):=sin(x)^3;
\end{verbatim}
set_tex_environment (":=", "$$", "$$");
tex (foo(x) := sin(x)^3);
=> $$foo(x):=sin(x)^3$$
(3) Change environment for plain text to nothing. Also,
suppress the paragraph operator (the operator just
carries the TeX environment property on behalf of the text).
get_tex_environment (paragraph);
=> [$$, $$]
tex (paragraph ("A guy walks into a bar."));
=> $${\it paragraph}\left(\mbox{{}A guy walks into a bar.{}}\right)$$
set_tex_environment (paragraph, newline, newline);
:lisp (defun tex-paragraph (x l r) (append l (list (l-string (cadr x))) r))
:lisp (setf (get '$paragraph 'tex) 'tex-paragraph)
tex (paragraph ("A guy walks into a bar."));
=>
A guy walks into a bar.
This stuff is implemented by introducing a new property,
TEX-ENVIRONMENT, which specifies the TeX environment
if present, and otherwise *TEX-ENVIRONMENT-DEFAULT* is
assumed. TEX-ENVIRONMENT is assigned to a few symbols
(only MDEFINE, MDEFMACRO, and MLABLE at present
because these were treated specially by TEX1 already).
The user interface to maintain TEX-ENVIRONMENT comprises these functions:
get_tex_environment_default ()
set_tex_environment_default (env_open, env_close)
get_tex_environment (x)
set_tex_environment (x, env_open, env_close)
Comments?
best
Robert Dodier