emacs - emacs 中的斜体字

标签 emacs elisp

我对 emacs 有点陌生。我正在用 latex 编辑一个文档,我想用斜体显示一些单词。我想要一个简单的宏,如果我将光标放在单词上,然后按组合键,该单词就会用斜体包围,如下所示 \textit{word}

是否有插件或快速方法来实现此目的或 emacs-lisp 宏?

最佳答案

就个人而言,我在 emacs 中使用 AUCTeX 进行 TeX/LaTeX 编辑。有很多关于如何使用它的很好的教程,例如A simpleton's guide to (…)TeX workflow with emacsEmacs as the Ultimate LaTeX Editor 。回答您的问题:是的,这是可能的,并且 AUCTeX 提供了工具:

手册中相关章节为Changing the Font ,摘自手册:

AUCTeX provides convenient keyboard shortcuts for inserting macros which specify the font to be used for typesetting certain parts of the text. They start with C-c C-f, and the last C- combination tells AUCTeX which font you want:

[...]

 C-c C-f C-i

    Insert italics ‘\textit{∗}’ text.

如果您使用事件区域执行该命令,它将将该区域放入格式化命令的参数中。如果没有区域,将插入格式化命令,然后您输入所需的内容。

通过将其与诸如 expand-region 之类的包结合起来或thing-cmds您可以按步骤更改单词的格式

  1. 使用 expand-region/mark-thing 标记单词
  2. 使用 AUCTeX 应用格式

人们可以将这两个步骤组合成一个即发即忘的函数(例如TeX-italicise-word,但是,我强烈建议不要这样做,因为(在我的观点)emacs的真正力量来自于组合函数/ Action 。

如果您确实坚持使用单键解决方案,我建议您阅读 Keyboard Macros它可用于以交互方式创建复合命令。

关于emacs - emacs 中的斜体字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29915483/

相关文章:

emacs - 我如何改进 Emacs Lisp Intro 的 "create index entries"练习的解决方案?

emacs - 如何将我的个人缩写添加到 Emacs 中的 emmet-mode 中?

emacs - 未检测到电对模式

emacs - 在组织模式下用标签组织笔记

找不到 Emacs 组织模式标签

emacs - 如何在 emacs minibuffer 中模拟返回

emacs - Emacs,如何获取当前缓冲区的目录?

emacs - 结合组织模式捕获和钻取模块来学习词汇

emacs - gnus 有 urlview (a la mutt) 吗?或者只是用 elisp 来提取 url?

Emacs 口齿不清 : how to append to the list "LaTeX-clean-intermediate-suffixes"?