5 ms·
Emacs as the Ultimate LaTeX Editor
- mih 12y agoAnyone seriously considering Emacs for LaTeX editing should also take a look at the yasnippet package. The customizable autocompletion shortcuts make it really easy to insert commands using just keywords. In my case this has proved to be very helpful especially when inserting figures or inline equations. I can create a snippet so that when I type fig+<tab> it inserts a \begin{figure}.. \end{figure}float and positions the cursor at the proper field saving me a lot of keystrokes.
- josteink 12y agoI've stopped using yasnippet because I find it too resource-intensive. It's especially noticeable on emacs-startup, even of good machines, and I've found myself not using it very often. So I decided that it wasn't worth the time. Just as a FYI to people on weaker hardware.
- agumonkey 12y agoI never really investigated why, I think it's because I use melpa as my main package repository, but yasnippet loads lazily now. This is assuming the 'old' package didn't have this set up by default.
- pmoriarty 12y agoMy main gripe with yasnippet is that its feature list is pretty lackluster compared to some advanced vim snippet plugins like xptemplate.[1] xptemplate has a bazillion features, and yasnippet is primitive in comparison. Just a simple example is that in xptemplate (and probably any respectable snippet plugin in vim) you can type a part of a snippet name, hit TAB, and it will expand the snippet whose partial name you typed (assuming there's no exact match). In yasnippet, you have to type out the full snippet name before it can be expanded. This is pretty annoying, especially for long snippet names. There are tons of other examples of far more advanced functionality, such as a variety of snippet repetition and embedding features. This comparative lack of features in yasnippet is pretty surprising, because emacs extensions are usually very feature rich, and everyone seems to love yasnippet. But I think that's because most emacs users don't know what they're missing. And before someone says it, yes, I know yasnippet gives you the ability to embed eLisp code in it, so I could potentially write all the functionality I need myself. But that's really beside the point. I'm talking about built-in features, not the ability to code up the features myself. [1] https://github.com/drmingdrmer/xptemplate https://github.com/drmingdrmer/xptemplate
- tuhdo 12y ago> Just a simple example is that in xptemplate (and probably any respectable snippet plugin in vim) you can type a part of a snippet name, hit TAB, and it will expand the snippet whose partial name you typed (assuming there's no exact match). In yasnippet, you have to type out the full snippet name before it can be expanded. This is pretty annoying, especially for long snippet names. Yes, you can do that as well. See the list of expansion methods with screenshots inside: https://capitaomorte.github.io/yasnippet/snippet-expansion.html#sec-2-3 https://capitaomorte.github.io/yasnippet/snippet-expansion.h.... You may interest in minibuffer prompting. You already have a built-in template system in Emacs called Srecode that allows you to program your templates: http://cedet.sourceforge.net/srecode.shtml http://cedet.sourceforge.net/srecode.shtml According to the homepage, "the core template text is based loosely on Google ctemplate".
- pmoriarty 12y agoI was hoping someone would say that was possible. Thanks, I'll play around with the available yas-prompt-functions. As for SRecode, that looks interesting but its documentation is impenetrable. Someone seriously needs to write a bunch of tutorials for that thing. Otherwise, I can't really tell if it can do what xptemplate is capable of or not. I found some comments from SRecode's author suggesting that it's intended for different uses from yasnippet: "Thus, the audience for yasnippet and SRecode is quite different. Of course you could do yasnippet like things with SRecode if someone took the time to improve the field-editing feature in SRecode, but that has not been my focus."[1] [1] - http://emacs-fu.blogspot.com/2010/09/interview-with-eric-ludlam-cedet.html http://emacs-fu.blogspot.com/2010/09/interview-with-eric-lud...
- tuhdo 12y agoI agree Srecode needs to improve its documentation. It took me a while to learn to use it by reading the actual templates written that come with CEDET. I may write a tutorial for it at some point. But not now. You can have a look at a sample template: https://github.com/emacsmirror/cedet/blob/f72ebbc52785013280fddea8b6b1626ddd7ee6b4/etc/srecode/c.srt https://github.com/emacsmirror/cedet/blob/f72ebbc52785013280... . Srt file has syntax highlighting in Emacs.
- pXMzR2A 12y agoC-c C-e fig TAB RET C-c C-e means "give me a new environment"
- mih 12y agoSure Auctex does provides kb-shortcuts. But rather than using predefined keystrokes, I prefer to use my own. Besides, snippets can be used for commands/environments for which AucTex provides no shortcut or for things such as macros.
- tincholio 12y agoAUCTeX has the LaTeX-environment function (C-c C-e by default) that does even better than that (inserts the figure environment, offers to center, creates a label, a caption, etc.), and also handles all environments, plus there's no need to create the snippets.
- mih 12y agoI just used figure as an example. If there's no predefined keystroke or function available such as in the case of LaTeX macros that you tend to use frequently, snippets can be of use. Of course one can do without them, but they're definitely worth considering if you use emacs regularly.
- alceta 12y agoI'm tired of these superlatives like 'THE best editor', it adds nothing to the quality of a blog entry.
- vsbuffalo 12y agoI hate the best editor debate because I think it's distracting from what's more important — what both editors can learn from each other and what both need to do to improve. I used Emacs for years, switched to Vim because of RSI, then recently switched back to emacs+evil. Frankly, for what I do most (R, R+knitr, C++ with clang autocomplete), no single editor is great. First, there's too little ability to switch between modes within a single buffer in both Vim and Emacs. The feature's entirely lacking in Vim AFAIK, and poly-mode in R uses a high level hack that (1) doesn't play well with other modes (including evil) and (2) has so thoroughly destroyed my documents in the past I refuse to use it now (mostly because it uses many buffers behind the scenes, which destroys undo history). In general, if you want flawless R support in certain blocks of text (as in a .Rnw file) in between LaTeX blocks that are fully connected to AucTeX, well... you're out of luck. And Vim... Vim-R-Plugin is useful, but it's sort of a painful hack to use tmux just to get R and Vim to talk (and I'm saying this even though I love Tmux). Vim has YouCompleteMe, which is smooth as silk compared to Emac's options (which are painful and poorly integrated, especially with clang). But some lower-level issue in Vim causes this constant error message in Vim whenever YouCompleteMe uses clang — bloody annoying. So overall, both editors have huge issues that would require serious overhauls or tedious bug fixing in various modes. Sure, Emacs does AucTeX better, but until it does everything better (or Vim does everything better) it's a flawed editor. Both are flawed editors. But sadly everyone thinks the best course of action is to start fresh — which usually creates a feature-poor flawed editor on a new shiny foundation, that fails to attract developers because it's feature poor. (apologies for ranting -- jetlag).
- RBerenguel 12y agoCode (live code) + LaTeX can be done with org-babel (kind of,) and I use mmm-mode (sorry, not on my computer now and don't remember the precise name, but it's on Melpa) and for multiple major modes in different blocks, works nicely (but don't know a way to keep the defined modes per section across sessions/file closes)
- melling 12y agoWell, the "best editor debates" do keep people from being insular. :-) Are the vi keybindings really better for your RSI? I've heard different stories. For example, http://changelog.complete.org/archives/661-so-long-vim-im-returning-to-emacs http://changelog.complete.org/archives/661-so-long-vim-im-re... There's a new ergoemacs mode that I haven't tried yet: http://ergoemacs.org http://ergoemacs.org Personally, I spend more time using IntelliJ, Xcode, and Sublime these days, but recently I started using Emacs again for a bunch of .org stuff. By the way, there's an Emacs StackExchange which will hopefully make emacs more accessible. http://emacs.stackexchange.com/questions/2671/how-can-i-get-fuzzy-code-completion http://emacs.stackexchange.com/questions/2671/how-can-i-get-...
- grayclhn 12y agoAUCTeX mode is great; less well known is CDLaTeX mode, which has a lot of quick abbreviations for mathematical symbols, etc. I'm a huge fan: https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/cdlatex.el https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/cdlatex.el
- JoshTriplett 12y agoI switched to vim years ago for everything else, but I still use emacs specifically for auctex. I have yet to find a vim equivalent nearly as convenient. In particular, C-c C-c as a do what I mean compiler (checking timestamps to figure out whether to run LaTeX, BibTeX, etc, as well as C-c C-e to insert an environment, and alt-enter to insert a newline and \item.
- martinbm 12y agoHave you tried looking at VIM-LaTeX (http://vim-latex.sourceforge.net http://vim-latex.sourceforge.net)? It does exactly what you described and is just as customisable as auctex. For example: <leader>ll will compile your document, multiple times if necessary, and show you warnings/errors in a new window, letting you hit enter on each to jump to the line. Lots of helpers for inserting environments, items, packages, too! But if you're used Emacs just for auctex, more power to you for harnessing the power of two awesome editors!
- pmoriarty 12y agoI just use snippets (via xptemplate) to do LaTeX editing in vim. For running LaTeX, BibTeX, pdftex, etc, I use LatexMk.[1] I would be interested to hear what AucTEX provides that the above combination can't. [1] - http://www.emacswiki.org/emacs/LatexMk http://www.emacswiki.org/emacs/LatexMk
- yummyfajitas 12y agoNavigation and label handling. M-j lets you jump to a section, C-( inserts a uniquely numbered \lab and C-) gives a menu for inserting a \ref to an existing label. (These may not be standard bindings - my .emacs is a horrible mess of legacy code dating back to a pre-git world.)
- JoshTriplett 12y agoI don't find snippets nearly as convenient as the built-in auctex keybindings. C-c C-e itemize <enter> item1 <alt-enter> item2 gives me (properly indented for surrounding context): \begin{itemize} \item item1 \item item2 \end{itemize} I could probably convince vim to do that, but auctex does it out of the box with no additional configuration required. Likewise, I could probably set makeprg to latexmk or rubber or some other DWIM script, but that ought to Just Work as easily as auctex's C-c C-c, and shouldn't require a pile of configuration. I haven't even found a way to bind <A-Enter> in vim's insert mode, because vim can't distinguish that from <Esc><Enter>.
- kyrre 12y agoI feel like the secret to being productive with LaTeX is not the editor, but the build script (latexmk).
- dredmorbius 12y agoMore details?
- kgabis 12y agoThe best latex editor I used so far is TexPad (https://www.texpadapp.com https://www.texpadapp.com), but it's only available on OSX and iOS...
- pmoriarty 12y agoCould you elaborate on that? What makes it the best for you? More to the point, in what ways is it better than AucTEX?
- kgabis 12y ago* It's a standalone and native OS X application * It has code completion * File and document navigation is easy thanks to tree view * It works out of the box, no dependencies other than TeX required
- scorpion032 12y agoThe best LaTeX editor I have found is [Latexian](http://tacosw.com/latexian/ http://tacosw.com/latexian/) In a discussion on Latex Editors, I find it surprising how it was not mentioned even, so far.
- pmoriarty 12y agoCould you elaborate on that? What makes it the best for you? More to the point, in what ways is it better than AucTEX?
- diarg 12y agoIndeed, Emacs rocks for LaTeX. It would rock harder is someone(tm) implemented a visual version of LaTeX, for small quick documents and for newbie accessibility.
- dredmorbius 12y agoThere's Lyx, though I've long found it harder to deal with than straight-up LaTeX. If you're doing quick small documents, Markdown and Pandoc may well be a better fix for you. A useful mode for working with LaTeX (or other tagged documents) is to have a build system which watches your source, re-builds it as you edit it, and a viewer which updates as the generated PDF is refreshed. You can do this with LaTeX, Markdown + Pandoc, or numerous other systems. It's quite powerful.
- dredmorbius 12y agoI'm seeing a lot of "X is best" or "y additional feature is powerful". Neither adds much to the discussion. Which isn't to say that posts such as this can't provide value. I've been using vim and its antecedents for over a quarter century, as well as well over another editors and authoring tools (closer to two dozen). Including a few forays into emacs-land. I find discussions of tools useful, and have added a few to my own suite in the past year. Most recently vim-outliner, an outlining plug-in for vim, also Pandoc, and in the past two years, for the first time after considering it for a long time, LaTeX. Describing WHY an editor or tool suits you, or SPECIFIC features it has or offers, is far more useful. It will also make the discussion here hugely more valuable than just pointing people at vim or emacs (again). Both are pretty easy to find without that help. Providing reasons and specific benefits -- much more valuable.
- hchenji 12y agoTry out TexStudio (http://texstudio.sourceforge.net/ http://texstudio.sourceforge.net/). Free, open source, integrates with MikTex, ctrl-space autocompletion for bibtex entries, can easily switch build chain from latex-dvi-ps-pdf to xelatex-pdf or pdflatex or latex-dvipdf.