You can do this by defining your own auto-fill-function
, and configuring LaTeX mode to use that:
;; define environments we don't want to autofill:
(defvar unfillable-envs '("figure"))
;; add more environments if you like, eg:
;; (defvar unfillable-envs '("figure" "tikzpicture"))
;; create a function to check the environment first, then fill:
(defun my-filtered-fill ()
(unless (member (LaTeX-current-environment) unfillable-envs)
(do-auto-fill)))
;; setup LaTeX/AucTex to use auto-fill-mode, but with our fill-function:
(defun my-tex-auto-fill ()
(auto-fill-mode)
(setq auto-fill-function 'my-filtered-fill))
(add-hook 'LaTeX-mode-hook 'my-tex-auto-fill)
Note that you can add different environments to unfillable-envs
if you want to block filling in other places.
You could accomplish the same thing by advising the fill function, but that can lead to unexpected problems if you're not careful.