auctex-devel
[Top][All Lists]
Advanced

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

algorithm.el: Wrong usage of TeX-dialect


From: Arash Esbati
Subject: algorithm.el: Wrong usage of TeX-dialect
Date: Tue, 18 May 2021 10:32:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50

Hi Uwe,

in algorithm.el, `TeX-dialect' seems to be in the wrong place.  It
should be the optional third argument to `TeX-add-style-hook'.
Currently, it is placed inside the hook.  I suggest the following
change:

--8<---------------cut here---------------start------------->8---
diff --git a/style/algorithm.el b/style/algorithm.el
index c493c829..73f0b5e6 100644
--- a/style/algorithm.el
+++ b/style/algorithm.el
@@ -35,7 +35,6 @@
   '("section")
   "Package options for the algorithm package.")

-
 (defun LaTeX-env-algorithm (environment)
   "Insert a algorithm-like ENVIRONMENT with caption and label."
   (let* ((pos (completing-read (TeX-argument-prompt t nil "Position")
@@ -54,13 +53,8 @@
       (when (and short-caption (not (string= short-caption "")))
         (insert LaTeX-optop short-caption LaTeX-optcl))
       (insert TeX-grop caption)
-      ;; ask for a label and insert it
-                                        ;      (LaTeX-label environment 
'environment)
-      ;; the longtable `\caption' is equivalent to a
-      ;; `\multicolumn', so it needs a `\\' at the
-      ;; end of the line.  Prior to that, add } to
-      ;; close `\caption{'
-      (insert TeX-grcl "")
+      ;; Add } to close `\caption{'
+      (insert TeX-grcl)
       ;; fill the caption
       (LaTeX-fill-paragraph)
       ;; Insert a new line and indent
@@ -69,15 +63,13 @@
       (LaTeX-newline)
       (indent-according-to-mode))))

-
 (TeX-add-style-hook
  "algorithm"
  (lambda ()
    (LaTeX-add-environments
-    '("algorithm"  LaTeX-env-algorithm ))
+    '("algorithm" LaTeX-env-algorithm))
    (TeX-add-symbols
-    '("listofalgorithms" 0))
-      TeX-dialect))
-
+    '("listofalgorithms" 0)))
+ TeX-dialect)

 ;;; algorithm.el ends here
--8<---------------cut here---------------end--------------->8---

I think the code currently also inserts two blanks lines if the \label is
omitted.  This part

    ;; Insert a new line and indent
    (LaTeX-newline)
    (LaTeX-label environment 'environment)
    (LaTeX-newline)

should read

    ;; Insert a new line and indent
    (LaTeX-newline)
    (when (LaTeX-label environment 'environment)
      (LaTeX-newline))

Can you please have a look?  TIA.

Best, Arash



reply via email to

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