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

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

Re: Convert some Latex expressions in Emacs.


From: Emanuel Berg
Subject: Re: Convert some Latex expressions in Emacs.
Date: Mon, 16 May 2022 06:49:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao wrote:

> 1. Remove the following stuff: `\begin{array}{l}',
> `\end{array}'.

Kill manually.

> 2. For each word, remove '{' and '}', spaces, and add *
> between two characters of it, i.e., `P^{5} Q^{2} R' should
> be changed to `P^5*Q^2*R'.

You can do this with `re-search-forward' and regular
expressions that also have subexpressions, you then refer back
to them in `replace-match'. E.g., eval the following

(while (re-search-forward "_\\(.*\\)_" (point-max) t)
  (replace-match "\\\\textit{\\1}") )

To change

  - That ain't _true_!
  - I _know_ right?

into

  - That ain't \textit{true}!
  - I \textit{know} right?

> 4. Change the first `\\' to new line.

If it just happens once, doing it manually is as fast or
faster as any other way, either that or it should be.

> 6. Change other `\\' to comma.

After doing the first manually, `replace-regexp', this
time no need for subexpressions tho.

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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