I want to create a style file for the tcolorbox environment. I have the following:

(add-hook 'LaTeX-mode-hook
      (lambda ()

However, I want Emacs to query for the optional [title=] parameter. How can I do that?

2 Answers 2


You should use the LaTeX-env-args function (see the documentation for more information). In your case:

   '("tcolorbox" LaTeX-env-args [TeX-arg-key-val (("title"))]))

There are some style files using this feature, you should check them out.

If you're writing a style file for the tcolorbox package, I strongly suggest you to submit it to the AUCTeX mailing list so it can be added upstream.

  • Well, I'm queried, but the result is simply [text I typed]. I'll check the documentation you pointed at. Thanks.
    – NVaughan
    Feb 4, 2015 at 1:11

Using @giordano's suggestion, and examining other styles, I managed to do this:

(defun LaTeX-tcolorbox-env-item-opt-label (environment)
  "Insert a `tcolorbox` environment with an optional title."
   (let ((label (TeX-read-string "(Optional) Title: ")))
     (concat (unless (zerop (length label))
               (format "[title={%s}]" label))))))

(add-hook 'LaTeX-mode-hook
          (lambda ()
             '("tcolorbox" LaTeX-tcolorbox-env-item-opt-label))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.