I've been experimenting with AucTeX, and I can't tell if this is a question that best belongs in the emacs forum, or here. If it belongs there, I will gladly move it.

I've been using the Latex-fill-environment option via C-c C-q C-e to automatically format my documents. However, I end up with a great deal of space to the right of my text. I have been playing with the frame size via (add-to-list 'default-frame-alist '(width . 104)), but that does not seem to change the behavior of the fill function.

What I would like to do is have AucTeX automatically wrap text at the width of my window using one of the different fill commands mentioned earlier. Right now it is wrapping at 72 characters (assuming that I can count properly right now) regardless of the window width.

Here are relevant parts of my .emacs file:

(setq default word-wrap t)
(load-theme 'manoj-dark)
(add-to-list 'default-frame-alist '(width . 104))

;; AucTeX stuff
(setq LaTeX-item-indent 0)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)

If I am interpreting things correctly, the first paragraph is emacs theme/properties related things, second paragraph is AucTeX related things.

EDIT: Not sure that it matters, but the first thing that I usually do when opening a tex file in emacs is to snap it to the left half of my screen. Then I can compile the document and view on the right half of my screen.

  • 1
    I just found the fill-column option on the emacs manual. This does the trick if I never resize the window, but doesn't make it adaptive (I think)
    – wolfste4
    Mar 30, 2016 at 5:15

2 Answers 2


For posterity, in case the original poster doesn't need this anymore: visual-line-mode will wrap long lines at the edge of the window without inserting hard line breaks. Try it with M-x visual-line-mode or enable it for LaTeX modes by adding it to your emacs initialization file with (add-hook 'LaTeX-mode-hook 'visual-line-mode).

  • This is exactly what I wanted. When I have done similar things before, it didn't do things like indent long items or work well with the C-c C-q C-e command in AucTeX to make formatting nice.
    – wolfste4
    May 2, 2016 at 20:01

Welcome to the trip into the realms of emacs.

Your idea is to adapt fill-column to the width of the windows?! Good idea for writing a text, but it won't work for people who write code.

I'm not an emacs expert, I haven't found a minor mode or something like that for adapting fill column to the size of the windows. If you still like the idea, after you stumbled upon fill-column, ask at the emacs site for help with programming such a function.

  • That's why I put this to the LaTeX community first. This may not work for all languages, but it sure makes sense for LaTeX, where line breaks in the markup don't matter and you want your code to read like a document in some places. When I was a windows user, I used TeX Works which looked great. But now I'm learning more languages and want an editor that is multilingual.
    – wolfste4
    Mar 30, 2016 at 14:00
  • Also, the fact that word wrapping exists (setq-default word-wrap t) suggests that the emacs world is flexible when it comes to certain coding rules (like the 70 characters in a line limit...isn't this a holdover from punch-card days?)
    – wolfste4
    Mar 30, 2016 at 14:14
  • I think that I didn't fully understand your statement about "writing code" initially. We do not want a file where things like line numbers change based on the width of the buffer. That would make the diff function useless. (Or other similar tools). Even the word-wrap option I mentioned wouldn't work like I want because while it visually breaks the end of the line, it doesn't do the same to the front of the line for things like long \item texts, and would ALSO have to change the spacing between words dynamically based on buffer width. I've been using fill-column and now love it.
    – wolfste4
    Apr 28, 2016 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .