replace normal font with superscript

Good evening
Thisis probably a rather stupid question and has been answered on this
list (somewhere) a million times ...

(The job is already done - manually - so there is no hurry; I would like
to know the trick.)

I had a piece of text (txt file), which contained a lot of things like
"m2" (square meter).
Working in Writer I tried to do a "find and replace" and turn the "2"
into superscript.
But I could not figure out how that works. I ALWAYS got "m2" as
superscript, even I selected only "2" and then format -> superscript.
(after I while of trying I gave up and replaced those number manually)

What is the trick required to turn "2" into superscript?
But ONLY in "m2" and not all "2", since there were lots of other numbers
too.

Thank you in advance.
Thomas

Thomas,

I have on my (Belgian) keyboard a key for ² and ³, so with me I'd
simply be a find & replace from "m2" to "m²"

Met vriendelijke groeten, Salutations distinguées, Kind Regards,

DRIES FEYS
CORPORATE SERVICES • Specialist Software Developer
T +32 56 43 42 45 • F +32 56 43 44 46 • dries.feys@tvh.com

Hi Thomas

Toppa-2 wrote

What is the trick required to turn "2" into superscript?
But ONLY in "m2" and not all "2", since there were lots of other numbers
too.

You are searching for a string (m2) but only want part of it to be changed.

I think this is not possible in any program, but would really be interested
to learn if it is.

Pedro

(2013/10/02 20:13), Pedro wrote:

Hi Thomas

Toppa-2 wrote

What is the trick required to turn "2" into superscript?
But ONLY in "m2" and not all "2", since there were lots of other numbers
too.

You are searching for a string (m2) but only want part of it to be changed.

I think this is not possible in any program, but would really be interested
to learn if it is.

Pedro

Many years ago I used to use Wordperfect and if I recall it correctly, WP did allow that.

If this is NOT possible, it is a real shame when you are working with technical text that contain lots
of symbols or number with some super- or subscripts.
Finding a whole lot of ASCII codes for different characters would not be very elegant either ...

In many programs this can be done with regular expressions. I just
checked in LO Calc, and there is an option for regex.

Of course, the "simple" way of doing this would be to search for "m2"
and replace with "m(2)" (sorry, this is a text only email, so you'll
have to imagine the second one has a superscript 2 instead of a 2 in
brackets).

When you know the term you are searching for, and know that you want to
replace only part of it, you can just use a replacement term that is
the same as the search term, with the correct part replaced. But when
you are trying to search for a term that can vary, and then want to
replace only part of the term, you need to use regexen.

Paul

This is probably a rather stupid question ...

In the absence of good evidence, I tend to assume there are no stupid questions - only perhaps stupid answers.

I had a piece of text (txt file), which contained a lot of things like "m2" (square meter). Working in Writer I tried to do a "find and replace" and turn the "2" into superscript. But I could not figure out how that works. I ALWAYS got "m2" as superscript, even I selected only "2" and then format -> superscript.

What is the trick required to turn "2" into superscript? But ONLY in "m2" and not all "2", since there were lots of other numbers too.

Here are two workarounds:

o Search for "m2" and replace with "m2" but superscripted - exactly as you have been able to do.
o Now search for just "m" and replace with "m", but use Format... in the "Search for" box to set Superscript and the same in the "Replace with" box to set Normal position. The temporarily superscripted "m"s will be restored to normal.
This relies on there being no existing superscripted "m"s, of course.

Or:

o Search for "m2" but click Find All. All the occurrences will be selected.
o Now search for "2" and replace with superscripted "2" but - here's the trick - click More Options and tick "Current selection only".

I trust this helps.

Brian Barker

Hi,
   Seems my previous reply did not reach all users. I wrote:

In the "Find and Replace" option type in m2 in the "Find" window, then in
the "Replace" window type in m and then, holding down the Alt key, type in
253 then release the Alt key. This places the ASCI code for supercript 2 in
the Replace window.

Cheers,

Paddy

Using Copy (from text) and Paste (into "Find and Replace" window) does not
work either. When you paste the m(2) into the Replace window it reverts to
standard 2. This ASCI workaround seems to be the only option at the moment.
This might be something that they could look at.

Paddy

In many programs this can be done with regular expressions. I just checked in LO Calc, and there is an option for regex.

We are talking about text (Writer) files here, but regular expressions work there too.

Of course, the "simple" way of doing this would be to search for "m2" and replace with "m(2)" (sorry, this is a text only email, so you'll have to imagine the second one has a superscript 2 instead of a 2 in brackets). When you know the term you are searching for, and know that you want to replace only part of it, you can just use a replacement term that is the same as the search term, with the correct part replaced.

The problem is that there appears to be no way in LibreOffice to set a replacement expression that is a mixture of formats - in this case Normal and Superscripted. It's all or nothing. Unless you know better ...

Brian Barker

When I had to do something similar, I wrote a macro :slight_smile:

If you do not know much about macros, you probably need to record one,
and I expect that the macro recorder is poor enough that the only real
solution would be to do the first one by hand, copy the correct result
to the clipboard, then record a macro that pastes the value and then
searches for the next occurrence. If you are left with a regular m2
selection, run the macro again. if not, well, you are finished.

Wouldn't a character style handle this? That would mean using
character styles, of course, but that is the first thing I thought of.

Regards,

It would ber nice to have users use "standard" font styles - say a
Times, Sans, or Serif, font?

The text in the posting below is really hard to read.

Brian Barker wrote

o Search for "m2" but click Find All. All the occurrences will be
selected.
o Now search for "2" and replace with superscripted "2" but - here's
the trick - click More Options and tick "Current selection only".

Nice solution :wink: I was hoping for a more complicated regex thing but this
does solve the problem.

This again proves that a simple solution is usually the best :slight_smile:

Thanks!

Hi :) 
I think i missed earlier emails about this because you can just select the 2 and then do
Format - Character - Position
and then use the radio buttons at the top to change to
*  super-script (that's the radio button at the very top)
*  normal (the button in the middle)
*  sub-script (at the bottom of the 3)
It's done as radio buttons because you can't have a character being more than one of those things at the same time (obviously)

So, now i am prolly going to find earlier emails that already say this or discount it or something and then just hide for a while. 
Regards from
Tom :slight_smile:

>In many programs this can be done with regular expressions. I just
>checked in LO Calc, and there is an option for regex.

We are talking about text (Writer) files here, but regular
expressions work there too.

Yes, sorry, I should have specified; I just happened to have Calc open,
so assumed that if Calc could do it, so could Writer.

>Of course, the "simple" way of doing this would be to search for
>"m2" and replace with "m(2)" (sorry, this is a text only email, so
>you'll have to imagine the second one has a superscript 2 instead of
>a 2 in brackets). When you know the term you are searching for, and
>know that you want to replace only part of it, you can just use a
>replacement term that is the same as the search term, with the
>correct part replaced.

The problem is that there appears to be no way in LibreOffice to set
a replacement expression that is a mixture of formats - in this case
Normal and Superscripted. It's all or nothing. Unless you know
better ...

I was actually referring to the previous comment about a way to replace
only part of the search term. But I see you are correct, the format
cannot be changed for only part of the search term, even using a regex.
Using undo, it appears that the replacement is done first, then the
formatting is done of the whole matched search term. I had assumed the
formatting would only be done on the replaced part.

For those interested, I will describe how to use a regex to replace
only part of a search term:

After checking the "Regular expressions" checkbox on the search window,
one can then use "(m)2" as the search term. The brackets make this a
numbered capturing group (one can even use names, but I won't go into
that syntax), and one can use that in the replacement term by using a
dollar sign to indicate a numbered group. So a replacement term of
"$12" would change nothing, as the "$1" refers to the first captured
group, the "m", and then the "2" is literal. The numbers confuse things
a little, so let's say instead we wanted to replace "man" with "woman",
we could do a search for "(man)" and use a replacement term of "wo$1".

For a more practical example that can't be done the simple way, let's
say you have written an article about John and Jane, but by accident
spelt their names without initial capitals throughout the document.
Instead of doing multiple search and replace operations, you can do it
all in one. If you use a search term of "j(ohn|ane)", this will match
all words that start with a "j" and are followed by either "ohn" or
"ane". Of course this matches both "john" and "jane", and the brackets
make the bit (whatever it is) that follows the "j" a numbered capture
group. Now in the replacement term you can use "J$1" to replace the
matched words with "J" and whatever initially followed the "j", i.e.
replace all "john"s with "John"s and all "jane"s with "Jane"s. This
example may seem a bit contrived, but there are plenty of times that
this does come in handy. Often, though, the regular expression can be
quite a bit more complex...

See http://www.regular-expressions.info/named.html for more info on
named capture groups, and that site is also an excellent reference for
regular expressions in general.

Regards

Paul

Andrew's email was sent as plain text, so displays using whatever font
your mail client is set to use. For me (Mozilla SeaMonkey), that's set
to Courier New for Western or Unicode text. However, the Content-Type
headers of Andrew's email and your reply indicate a Japanese character
set is used, for which my client is set to use MS Gothic. I guess you're
seeing something similar - MS Gothic does appear a bit more difficult to
read for Western text, but presumably it includes Japanese characters
while Courier New doesn't.

Mark.

Kracked_P_P---webmaster wrote:

Hi All

This past week I was given a small job to do to produce some 40-odd individual labels.

I remembered that Writer has a Label Function so decided to use that. The labels were 10 to aa A4 page in two columns (Unknown type - local manufacturer) so I decided to use "user" to set-up the spacing.

No matter what I tried the Label Box will *NOT* accept any label size - whatever I enter in there it changes back to 0.10cm every time!! (I also feel the box labels could be made very much more intuitive!! - ie "Horizontal Pitch" could be "Label Spacing" etc.

I'm using PCLinuxOS 2013-08 and I tried with an old LO ver 3 and my ver 4.12 - same result.

Has anybody noticed this or know of a work-round??

I eventually had to produce the labels I needed in Scribus - a DTP Program.

Thanks

IanW
Pretoria RSA

Yes! Using frames for label production has been a thorn in my hide for years now and yet it is so easy to create a table-based template - I've created dozens. Maybe you should do the same? It's a certainty that Scribus is overkill. :slight_smile:

Peter HB

Last time I printed labels using LO, I just used a .doc label template
from Avery for the label sheets I used.

That can be a pain for some people, but it works the best for me.

Table based! :wink:

Table style templates have worked great for me, with very accurate placement of the text on the label. I've been doing labels in OpenOffice and LibreOffice together for about 8 years. American size table style templates are available here:
http://www.worldlabel.com/Pages/openoffice-template.htm

Don