2

I should mention that I want to do this in emacs with its version of regex.

Here's an example. I would like to change

    -    \item
    -    Property Agreement
    -    Your agreement changing Joint Tenancy
    -    property into Community property.

to

    -    \item
    -    \textbf{Property Agreement}\\
    -    Your agreement changing Joint Tenancy
    -    property into Community property.

The regex to change the "Property Agreement" line is no problem. The problem I'm having is making it happen to lines immediately following the \item lines in the list and only those lines. The \\ is the new-line code in LaTeX; not an emacs-regex code for a single slash.

1
  • 1
    Any reason not to do this with a keyboard macro?
    – phils
    Oct 28, 2021 at 3:30

2 Answers 2

5

How about this? I left out the slashes and other details for simplicity, but it still demonstrates a solution:

\(item.*\n.+\)Property Agreement -> \1{Property Agreement}

Note that if you do this interactively then type C-q C-j instead of \n.

2
  • You forgot the \\textbf in the replacement string which should be \1\\textbf{Property Agreement}
    – gigiair
    Oct 28, 2021 at 8:59
  • @gigiair I indicated in the answer that I left out details for simplicity. I demonstrated the principle, from that it's easy enough to add custom details.
    – Tom
    Oct 28, 2021 at 13:29
0

This worked:

regex = ^\(\\item.*C-qC-j\)\(.*\)

replacement = \1\\textbf{\2}\\\\

Thanks for your help.

Before

\item 
Property Agreement
Your agreement changing Joint Tenancy
property into Community property.
\item 
Funding Instructions
Instructions for the proper transfer of your
assets into the name of your Living Trust.
\item 
Certificate of Trust 
Selected Living Trust provisions that will
be helpful in funding and administering
your Living Trust.

After

\item 
\textbf{Property Agreement}\\
Your agreement changing Joint Tenancy
property into Community property.
\item 
\textbf{Funding Instructions}\\
Instructions for the proper transfer of your
assets into the name of your Living Trust.
\item 
\textbf{Certificate of Trust}\\
Selected Living Trust provisions that will
be helpful in funding and administering
your Living Trust.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.