* Re: How to create a function to italicize in latex in emacs?
2011-07-26 10:58 How to create a function to italicize in latex in emacs? Pedro Costa
@ 2011-07-27 19:31 ` dejfson
2011-07-27 19:50 ` Andreas Röhler
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dejfson @ 2011-07-27 19:31 UTC (permalink / raw)
To: Pedro Costa; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 507 bytes --]
This is already done. Install auctex and you can use shortcuts like c-c c-f
c-i if you want font to be in italics
D.
sent from mobile phone
Dne 27.7.2011 21:19 "Pedro Costa" <psdc1978@gmail.com> napsal(a):
> Hi,
>
> 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?
>
> Thanks,
>
[-- Attachment #2: Type: text/html, Size: 723 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to create a function to italicize in latex in emacs?
2011-07-26 10:58 How to create a function to italicize in latex in emacs? Pedro Costa
2011-07-27 19:31 ` dejfson
@ 2011-07-27 19:50 ` Andreas Röhler
2011-07-27 19:53 ` suvayu ali
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2011-07-27 19:50 UTC (permalink / raw)
To: help-gnu-emacs
Am 26.07.2011 12:58, schrieb Pedro Costa:
> Hi,
>
> 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?
>
> Thanks,
>
>
Hi,
running the code below
you need a package thing-at-point-utils.el
from
http://launchpad.net/s-x-emacs-werkstatt/thing-at-point-utils/1.2/+download/thing-at-point-utils-1.2.tgz
otherwise
replace (ar-bounds-of-word-atpt) by a function delivering the borders of
the word, a cons
(defun textit ()
(interactive "*")
(let* ((bounds (ar-bounds-of-word-atpt))
(beg (car bounds))
(end (copy-marker (cdr bounds))))
(goto-char beg)
(insert "\\textit{")
(goto-char end)
(insert "}")))
HTH,
Andreas
--
https://launchpad.net/python-mode
https://launchpad.net/s-x-emacs-werkstatt/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to create a function to italicize in latex in emacs?
2011-07-26 10:58 How to create a function to italicize in latex in emacs? Pedro Costa
2011-07-27 19:31 ` dejfson
2011-07-27 19:50 ` Andreas Röhler
@ 2011-07-27 19:53 ` suvayu ali
2011-07-27 21:16 ` Eric Abrahamsen
2011-07-28 3:54 ` R. Clayton
4 siblings, 0 replies; 6+ messages in thread
From: suvayu ali @ 2011-07-27 19:53 UTC (permalink / raw)
To: Pedro Costa; +Cc: help-gnu-emacs
On Tue, Jul 26, 2011 at 12:58 PM, Pedro Costa <psdc1978@gmail.com> wrote:
> Hi,
>
> 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?
>
Not exactly the answer you are looking for but you might want to look
at org-mode. It lets you format text with simple markups (e.g.
/italicise/, *bold*, _underline_ ) and much more. And then you can
export an org-mode document to several formats, including latex.
http://orgmode.org/
http://orgmode.org/worg/
> Thanks,
>
GL.
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to create a function to italicize in latex in emacs?
2011-07-26 10:58 How to create a function to italicize in latex in emacs? Pedro Costa
` (2 preceding siblings ...)
2011-07-27 19:53 ` suvayu ali
@ 2011-07-27 21:16 ` Eric Abrahamsen
2011-07-28 3:54 ` R. Clayton
4 siblings, 0 replies; 6+ messages in thread
From: Eric Abrahamsen @ 2011-07-27 21:16 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, Jul 26 2011, Pedro Costa wrote:
> Hi,
>
> 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?
If you're editing a latex file you should be using a latex mode to do
that, and the latex mode will provide these sorts of commands. Auctex is
a great one: using that, select the word and then hit C-c C-f C-i to
surround it with \textit{}. Or just hit the command with nothing
selected, and point will be left between the braces, ready to type.
Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to create a function to italicize in latex in emacs?
2011-07-26 10:58 How to create a function to italicize in latex in emacs? Pedro Costa
` (3 preceding siblings ...)
2011-07-27 21:16 ` Eric Abrahamsen
@ 2011-07-28 3:54 ` R. Clayton
4 siblings, 0 replies; 6+ messages in thread
From: R. Clayton @ 2011-07-28 3:54 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread