yatex

changeset 259:7d4f8f3d540d dev

Do not count sub-environment inside math-environment as a counter.
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 13 Feb 2012 15:26:07 +0900
parents 3995f7fc6678
children e2899f13e8a4
files yatexadd.el
diffstat 1 files changed, 26 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/yatexadd.el	Sun Feb 12 17:56:43 2012 +0900
     1.2 +++ b/yatexadd.el	Mon Feb 13 15:26:07 2012 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX add-in functions.
     1.5  ;;; yatexadd.el rev.20
     1.6  ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Sun Feb 12 10:48:23 2012 on firestorm
     1.8 +;;; Last modified Mon Feb 13 15:20:11 2012 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;;
    1.12 @@ -606,6 +606,7 @@
    1.13        (setq cc (current-column))
    1.14        (if (= (char-after (point)) ?\\) (forward-char 1))
    1.15        (cond
    1.16 +       ;; In each codition, 'inspoint and 'boundary should be set
    1.17         ((looking-at YaTeX-sectioning-regexp)
    1.18  	(setq command (YaTeX-match-string 0))
    1.19  	(skip-chars-forward "^{")
    1.20 @@ -680,14 +681,19 @@
    1.21  	;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)"))
    1.22  	(setq boundary
    1.23  	      (save-excursion
    1.24 -		(if (YaTeX-re-search-active-forward
    1.25 -		     (concat
    1.26 -		      YaTeX-ec-regexp "\\("
    1.27 -		      (if exp1 "" "\\\\\\|")
    1.28 -		      "end{" env "}\\)")
    1.29 -		     r-escape nil 1)
    1.30 -		    (match-beginning 0)
    1.31 -		  (1- (point))))
    1.32 +		(or (catch 'bndry
    1.33 +		      (while (YaTeX-re-search-active-forward
    1.34 +			      (concat
    1.35 +			       YaTeX-ec-regexp "\\("
    1.36 +			       (if exp1 "" "\\\\\\|")
    1.37 +			       "\\(end{" env "\\)}\\)")
    1.38 +			      r-escape nil 1)
    1.39 +			(setq foundpoint (match-beginning 0))
    1.40 +			(if (or (match-beginning 2) ;end of outer math-env
    1.41 +				(equal env (YaTeX-inner-environment t)))
    1.42 +			    ;; YaTeX-inner-environment destroys match-data
    1.43 +			    (throw 'bndry foundpoint))))
    1.44 +		    (1- (point))))
    1.45  	      inspoint boundary))
    1.46         ((looking-at "footnote\\s *{")
    1.47  	(setq command "footnote")
    1.48 @@ -718,6 +724,7 @@
    1.49  		    (match-beginning 0)
    1.50  		(1- (point))))))
    1.51         (t ))
    1.52 +      ;;cond by kind of labeling ends here.
    1.53        (if (save-excursion (skip-chars-forward " \t") (looking-at "%"))
    1.54  	  (forward-line 1))
    1.55        (cond
    1.56 @@ -754,6 +761,7 @@
    1.57  	(if mathp nil 
    1.58  	  (insert "\n")
    1.59  	  (YaTeX-reindent cc))
    1.60 +	(put 'YaTeX::ref-getset-label 'foundpoint (point))
    1.61  	(insert (format "\\label{%s}" newlabel))
    1.62  	newlabel)))))
    1.63  
    1.64 @@ -904,8 +912,6 @@
    1.65  			      e0 (match-end 1)))
    1.66  		    (funcall output (format "--subequation--%s" label) e0)))
    1.67  		 ((string-match mathenvs cmd) ;;if matches mathematical env
    1.68 -		  ;(skip-chars-forward "} \t\n")
    1.69 -		  ;(forward-line 1) ;2004/1/25
    1.70  		  (skip-chars-forward "}")
    1.71  		  (setq x (point)
    1.72  			envname (substring
    1.73 @@ -922,15 +928,15 @@
    1.74  		      (while (YaTeX-re-search-active-forward
    1.75  			      (concat
    1.76  			       "\\\\end{\\(" (regexp-quote envname) "\\)";;(1)
    1.77 -			       (if YaTeX-use-AMS-LaTeX
    1.78 -				   "\\|\\\\\\(notag\\)") ;;2
    1.79 +			       "\\|\\\\\\(notag\\)" ;;2
    1.80  			       (if (string-match
    1.81  				    YaTeX::ref-mathenv-exp1-regexp  cmd)
    1.82 -				   "" "\\|\\\\\\\\$")
    1.83 +				   "" "\\|\\(\\\\\\\\\\)$") ;;3
    1.84  			       )
    1.85  			      percent nil t)
    1.86  			(let*((quit (match-beginning 1))
    1.87  			      (notag (match-beginning 2))
    1.88 +			      (newln (match-beginning 3))
    1.89  			      (label ".......................") l2
    1.90  			      (e (point)) (m0 (match-beginning 0))
    1.91  			      (ln (YaTeX-string-width label)))
    1.92 @@ -938,7 +944,12 @@
    1.93  			   (notag
    1.94  			    (YaTeX-re-search-active-forward
    1.95  			     "\\\\\\\\" percent nil 1)
    1.96 -			    (setq x (point)))
    1.97 +			    (setq x (point))) ;use x as \label search bound
    1.98 +			   ((and newln	; `\\' found
    1.99 +				 (not (equal (YaTeX-inner-environment)
   1.100 +					     envname)))
   1.101 +			    (YaTeX-end-of-environment)
   1.102 +			    (goto-char (match-end 0)))
   1.103  			   (t
   1.104  			    (if (YaTeX-re-search-active-backward
   1.105  				 YaTeX::ref-labeling-regexp