alphapapa / outshine

Org-mode for non-Org buffers
GNU General Public License v2.0
212 stars 23 forks source link

outshine-cycle not working in latex mode #85

Closed HumHongeKamyaab closed 3 years ago

HumHongeKamyaab commented 3 years ago

I want to use outshine minor mode in latex mode.

When I use M-x outshine-cycle on any \section{foo}, I dont get folding of section like in org-mode, but instead get following message.

outline-back-to-heading: Before first heading

I guess I am using outshine-mode in wrong way.

alphapapa commented 3 years ago

Please see #74.

HumHongeKamyaab commented 3 years ago

Thanks @alphapapa for pointing in right direction.

Following snippet from https://github.com/alphapapa/outshine/issues/63#issuecomment-485134720, worked for me.

(add-hook 'LaTeX-mode-hook #'(lambda ()
                               (outshine-mode 1)
                               (setq outline-level #'LaTeX-outline-level)
                               (setq outline-regexp (LaTeX-outline-regexp t))
                               (setq outline-heading-alist
                                     (mapcar (lambda (x)
                                               (cons (concat "\\" (nth 0 x)) (nth 1 x)))
                                             LaTeX-section-list))))

If you need folding for \begin also, you can customize LaTeX-section-list as

    (setq LaTeX-section-list '(
                               ("part" 0)
                               ("chapter" 1)
                               ("section" 2)
                               ("subsection" 3)
                               ("subsubsection" 4)
                               ("paragraph" 5)
                               ("subparagraph" 6)
                               ("begin" 7)
                               )
          )

where ("begin" 7) is added in a list in addition to default ones.