• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
10

GREP for formula superscript

New Here ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Hello, 
may anyone help to convert X^(2-x)(4-x) + 18y to the part after ^ in superscript (only this part: "^(2-x)(4/6) " before +)?


TOPICS
How to , Scripting , UXP Scripting

Views

202

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

I believe the only way to apply superscript would be by using a Character Style; that is, use GREP to select the superscript string and apply the style.

 

It may be difficult to write a GREP string that can distinguish the end of a complex string like that, though, unless there is some kind of consistent marker, separator or terminator, or the strings are consistent in format.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Hi @Eunice36085839l2u9, this is one of those questions that is easy to answer correctly, but the answer probably won't help you, because your example cannot capture the actuality.

 

But here's the easy answer, and maybe it will help.

 

\^\S+

 

If you put this into a grep style to trigger a "superscript" character style you will get this:

Screenshot 2024-03-15 at 09.25.49.png 

It simply makes everything superscript from the caret (^) onwards and stops before a space.

 

Do you want the caret removed? Probably. But if you do, the grep style won't work. But you could hide it like this:

Screenshot 2024-03-15 at 09.32.52.pngScreenshot 2024-03-15 at 09.33.39.png

Edit: I added a demo .indd file so you can look at this and type some formulas to test.

 

Or maybe you could use the greps I specified to do a Find/Change Grep to set a character style. That way you'd more-easily be able to override any false superscripts that occurred.

 

Another approach would be to look around for any online equation editors that could export as svg. I think there are some, but I don't know them off hand.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

That works except where if somewhere there was no space before the plus (4/6)+ the plus is found

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Yep. If this method is to work, then probably some spaces would need to be added manually. Note that, for presentation purposes, they could zero-width or thin spaces.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

Muito obrigado!!! testei aqui e funcionou, você ajudou bastante. 8)✌️

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2024 Mar 16, 2024

Copy link to clipboard

Copied

LATEST

Great to hear! 8)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

You say after ^ but then say only this part "^(2-x)(4/6)" before +

where ^ is part of what you want to find after?
Do you want to include the ^ or not?

 

Anyway if you want to include it 

(?<=\^)(\(.*?\)\(.*?\))(?= *\+)

 If you don't

\^(\(.*?\)\(.*?\))(?= *\+)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines