help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a function to italicize in latex in emacs?


From: R. Clayton
Subject: Re: How to create a function to italicize in latex in emacs?
Date: Wed, 27 Jul 2011 23:54:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

I would like to italicize a word in latex in emacs automatically.  Instead of
write \textit{word}, I would like to select the "word" and then write M-x <my
command> and it's added textit around the word. Do I have to create a lisp
function in .emacs? How do I do that?

  This is how I do it:

    (defun latex-surround-word (before after)

    "Add the given prefix and suffix to the word at point."

      (or (looking-at "\\<") (search-backward-regexp "\\<"))
      (insert before)
      (search-forward-regexp "\\>")
      (insert after))


    (defun latex-ital-word ()

    "Set the word at point in italics."

      (interactive)
      (latex-surround-word "{\\it " "\\/}"))


    (define-key latex-mode-map "\C-cfi" 'latex-ital-word)

  Put those and similar in a file and load the file as part of the latex mode
  hook.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]