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

Replace "CO2" by a "2" in subscript

New Here ,
May 11, 2023 May 11, 2023

Hi everyone !
I have an InDesign document with more than 400 times "CO2". 
I absolutely need to replace all "CO2" by CO2 : the "2" has to be in subscript.
Is there a way to use the tool "Replace" with subscript ? 
Thanks

TOPICS
How to
3.0K
Translate
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

correct answers 1 Correct answer

Community Expert , May 11, 2023 May 11, 2023

Use GREP!

Create a subscript character style, then create a Paragraph style that had that character style to be used with this GREP:

(?<=CO)2

 

Do you have NO2 and H2O as well? You can catch them all in one GREP:

([CN]O)\K2|(H)\K2(?=O)

Translate
Community Expert ,
May 11, 2023 May 11, 2023

Use GREP!

Create a subscript character style, then create a Paragraph style that had that character style to be used with this GREP:

(?<=CO)2

 

Do you have NO2 and H2O as well? You can catch them all in one GREP:

([CN]O)\K2|(H)\K2(?=O)

Translate
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 ,
Feb 08, 2024 Feb 08, 2024

How can this be solved so that the "2" is not shown as a subscript but as small capital?

Translate
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 Beginner ,
Aug 22, 2024 Aug 22, 2024

When creating the character style, don't choose "position: subscript", but instead choose "Case: small caps". Both options can be found in the Character Styles Options menu, on the Basic Character Formats tab

Translate
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 Beginner ,
Aug 22, 2024 Aug 22, 2024

I added ([cn]o)\K2|(h)\K2(?=o) to also apply this to all lowercase instances (co2, no2, h2o) too, but how do I capitalize the letters? Can I alter this GREP, do I make a new GREP?

Translate
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 Beginner ,
Aug 22, 2024 Aug 22, 2024
LATEST

In case anione else wonders, this is how I wound up doing it: I merged Frans' uppercase GREP and my lowercase GREP together into:

((?i)[CN](?i)O)\K2|((?i)H)\K2(?=(?i)O)

 

and I added a new GREP to capitalize all lowercase instances:

(?i)[cn]o(?=2)|(?i)h(?=2)|(?<=2)o

 

There might be a more effcient GREP string, but this seems to be working

Translate
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