开发者

How do I fully-justify latex code on EMACS

I want to fully-justify latex code on EMACS so that my latex code will look better. For example, I remember my advisor sending me latex in fully justified way like this:

In ~\cite{Hummel2004},  authors described  an approach  for harvesting
software components from the Web. The basic  idea is to use the Web as
the  underlying repository,  and to  utilize standard  search engines,
such  as Google,  as开发者_如何转开发  the means  of  discovering appropriate  software
assets.  Other  researchers  have crawled  through  Internet  publicly
available  CVS repositories  to  build their  own  source code  search
engines (e.g., SPARS-J)~\cite{Matsushita2005}.

I suppose that his column-width is set to 70 columns. Could someone give me a hint?


The standard fill.el package includes the command justify-current-line which is part of what you need. From the function help:

Do some kind of justification on this line.
Normally does full justification: adds spaces to the line to make it end at
the column given by `current-fill-column'.
Optional first argument how specifies alternate type of justification:
it can be `left', `right', `full', `center', or `none'.
If how is t, will justify however the `current-justification' function says to

And other posters have already given you the magicall invokation:

M-x set-justification

As a philosophical side note, the point of fixed-wdith text justification is to fake real typography on a inflexible output device. So applying it to LaTeX source seems a little odd to me. Moreover, I have been using the "one sentence to a line" approach to LaTeX documents for some months now, and find that it really does improves both the editability and the source-control behavior of LaTeX, so I would recommend against doing this.


If you select the region, and then press Ctrl-u M-x fill-region you get "full justification".


M-x set-justification-full

Use Refill mode afterwards to not have to run the command again after typing.


To get line wrap in the file itself (as opposed to something like longlines-mode that does not alter the structure of the file), I use auto-fill-mode, which automatically applies M-q (fill-paragraph) to each paragraph. For example, I use auto-fill-mode in mail-mode. You could do something similar with your LaTeX mode with a hook like this:

(add-hook 'TeX-mode-hook 'turn-on-auto-fill)

Assuming your TeX mode's hook is TeX-mode-hook.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜