简体   繁体   English

emacs中的斜体字

[英]Italicise word in emacs

I am slightly new to emacs. 我对emacs有点陌生。 I am editing a document in latex and I have words that I would like to put in italics. 我正在用乳胶编辑文档,我想用斜体字表示。 I would like a simple macro where if I place a cursor on the word, and hit a key combination the word is sorrounded with italics like this \\textit{word} . 我想要一个简单的宏,在该宏中,如果将光标放在单词上,然后按组合键,则该单词会用\\textit{word}这样的斜体字\\textit{word}

Is there a plugin or a quick way to achieve this or an emacs-lisp macro? 是否有插件或快速方法来实现此目标或emacs-lisp宏?

Personally, I use AUCTeX for TeX/LaTeX editing in emacs . 就个人而言,我在emacs使用AUCTeX进行TeX / LaTeX编辑。 There is a number of good tutorials on how to use it out there, eg A simpleton's guide to (…)TeX workflow with emacs or Emacs as the Ultimate LaTeX Editor . 关于如何使用它,有很多很好的教程,例如, 使用emacsEmacs作为Ultimate LaTeX Editor的 (…)TeX工作流程的简单指南 To answer your question: yes this is possible and AUCTeX provides the tools: 要回答您的问题:是的,这是可能的,并且AUCTeX提供了以下工具:

The relevant chapter in the manual is Changing the Font , excerpt from manual: 手册中的相关章节是“ 更改字体” ,摘自手册:

AUCTeX provides convenient keyboard shortcuts for inserting macros which specify the font to be used for typesetting certain parts of the text. AUCTeX提供了方便的键盘快捷键,用于插入宏,这些宏指定用于排版文本某些部分的字体。 They start with Cc Cf, and the last C- combination tells AUCTeX which font you want: 它们以Cc Cf开头,最后一个C-组合告诉AUCTeX您想要哪种字体:

[...] [...]

 C-c C-f C-i

    Insert italics ‘\textit{∗}’ text.

If you execute the command with an active region it will place that region into the argument of the formatting command. 如果使用活动区域执行命令,它将将该区域放入formattinging命令的参数中。 Without a region, the formatting command will be inserted and you and enter the desired content. 如果没有区域,将插入格式化命令,然后您输入所需的内容。

By combining this with a package such as expand-region or thing-cmds you can change the format of a word in to steps 通过将其与诸如expand-regionthing-cmds类的软件包结合使用,您可以将单词的格式更改为steps

  1. Mark the word(s) using expand-region / mark-thing 使用expand-region / mark-thing单词
  2. Apply format using AUCTeX 使用AUCTeX应用格式

One could combine those two steps into one fire-and-forget function (eg TeX-italicise-word , however, I strongly advise against doing so because (in my opinion) emacs ' true power comes from composing functions / actions. 可以将这两个步骤组合为一个“ TeX-italicise-word功能(例如, TeX-italicise-word ,但是,我强烈建议您不要这样做,因为(我认为) emacs的真正力量来自于组合功能/动作。

If you really insist on a single-key solution I suggest you read up on Keyboard Macros which can be used to create composite commands in an interactive manner. 如果您真的坚持使用单键解决方案,建议您阅读键盘宏 ,该可用于以交互方式创建复合命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM