This is related to this Emacs.SE question.

I use the code from the answer:

(setq LaTeX-begin-regexp "\\(?:begin\\|if@\\)\\b")
(setq LaTeX-end-regexp "\\(?:end\\|else\\|fi\\)\\b")
(defun LaTeX-indent-level-count ()
  "Count indentation change caused by all \\left, \\right, \\begin, and
\\end commands in the current line."
      (let ((count 0))
        (narrow-to-region (point)
                             (concat "[^" TeX-esc "]"
                                     "\\(" LaTeX-indent-comment-start-regexp
        (while (search-forward TeX-esc nil t)
            ((looking-at "left\\b")
             (setq count (+ count LaTeX-left-right-indent-level)))
            ((looking-at "right\\b")
             (setq count (- count LaTeX-left-right-indent-level)))
            ((looking-at LaTeX-begin-regexp)
             (setq count (+ count LaTeX-indent-level)))
            ((looking-at "else\\b"))
            ((looking-at LaTeX-end-regexp)
             (setq count (- count LaTeX-indent-level)))
            ((looking-at (regexp-quote TeX-esc))
             (forward-char 1))))

But instead of getting this indentation:


I do get


Hoe to get the \else in line with \if and \fi?

  • What happens if you change if@ into ifx, i.e., (setq LaTeX-begin-regexp "\\(?:begin\\|ifx\\)\\b") and try it again? – Arash Esbati Jan 21 '20 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.