auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] change: documents with $$ to \begin{documents}


From: Lars Madsen
Subject: Re: [AUCTeX-devel] change: documents with $$ to \begin{documents}
Date: Mon, 5 Jan 2015 08:28:19 +0000

I hacked together this one at some point


(defun fix-double-dollar-to-eqstar ()
  (interactive)
 (defun fix-double-dollar-to-eqstar ()
  (interactive)
  (let (
        (start (point)) 
        (case-fold-search nil)
        )
    (save-excursion
      (beginning-of-buffer)
      (while (re-search-forward 
              (concat 
               "\\$\\$"
               "\\(\\(.*?\n?\\)*\\)"
               "\\$\\$"
               )
              nil t
              )
        (catch 'continue
          (when (TeX-in-comment)
            (goto-char (match-end 0))
            (throw 'continue nil)
            )
            (replace-match (concat 
                            (regexp-quote TeX-esc)
                            "begin{equation*}"
                            "\\1"
                            (regexp-quote TeX-esc)
                            "end{equation*}"
                            )
                           t
                           )
            ) ;; end catch
        ) ;;  end while
      )
    )
)

Since people also tend to use 

$$ ... $$ 

it might be an idea to look out for those as well have put then into a more 
readable form.

I have a macro that can do that as well, though need further testing.

BTW: at one point I got caught by someone writing something like

$f(x)=$$x$

That *is* valid, but the macro of course does not gard against it.


/Lars Madsen
Institut for Matematik / Department of Mathematics
Aarhus Universitet / Aarhus University
Mere info: http://au.dk/address@hidden / More information: 
http://au.dk/en/address@hidden


________________________________________
From: address@hidden address@hidden on behalf of Uwe Brauer address@hidden
Sent: 03 January 2015 23:57
To: auctex-devel
Subject: [AUCTeX-devel] change: documents with $$ to \begin{documents}

Hi[1]

Sometimes I receive documents with have basically only
$$
\int f =0
$$
constructions instead of say
\begin{displaymath} or {equation*} etc.

Anybody has a idea how to change the evil $$ to true latex constructs by
using sophisticated regexp?

thanks

Uwe Brauer


Footnotes:
[1]  happy new year




reply via email to

[Prev in Thread] Current Thread [Next in Thread]