[Partial workaround] Set relative (dynamic) font size to hyperlinks

Discuss the word processor
Post Reply
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

[Partial workaround] Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

I am using a separate font for my hyperlinks style, and have the following specified:
  • Font: Biryani Light
  • Size: 72 %
My regular font is EB Garamond.

The problem I have, is that hyperlinks—though they flow well with the main body text—do not flow with the font size of the footnotes; it remains 82 % of the main body text size, rather than 82 % of the foot note text size; in other words, it is way too large. How can I define the URL style so it resizes the font to whichever environment it is set in?
Last edited by CannedMan on Wed Feb 22, 2023 1:35 am, edited 4 times in total.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

In the attached image, the problem is easy to spot. In the body text (upper half) the hyperlink flows with the x-height of the main body text; in the footnote, the x-height of the hyperlink is far too high. How can this be rectified?
Attachments
Image of hyperlink compared to x-height in body text and footnote text.
Image of hyperlink compared to x-height in body text and footnote text.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
JeJe
Volunteer
Posts: 3085
Joined: Wed Mar 09, 2016 2:40 pm

Re: Set relative (dynamic) font size to hyperlinks

Post by JeJe »

Its set by the Character Style "Internet Link".
Create a new Character Style with smaller font size and apply that to hyperlinks in the footnote.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Zizi64
Volunteer
Posts: 11490
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Set relative (dynamic) font size to hyperlinks

Post by Zizi64 »

Create a new Character Style with smaller font size and apply that to hyperlinks in the footnote.
And you can manage the new style as a child Style of the previous hyperlink paragraph Style, and you can set the Font size relatively to the parent Style: for example 60%. When you will change the size of the Font in the Parent Style, the Fornt size in the child Style will be modified automatically.
(At least it works in my LibreOffice...)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

That is what I have attempted, but it will not apply.

In the attached image, the above link is a true hyperlink (that is, it is a clickable hyperlink with all the necessary properties) which has the character style for hyperlinks in footnotes added to it; it is exactly the same as before. The below link is a fake hyperlink. It is formatted to look as though it is a hyperlink, but is not clickable and is only text.

The desired output is that when I apply the hyperlink in footnotes character style, the above link will look as the below link. Note that when left-clicking inside the true hyperlink (before adding the hyperlink in footnotes character style), the style list does not display it as a URL, as the style is automatically formatted. This is the expected behaviour, as the exact same things happens when e.g. trying to view the style for footnote anchors (they will list as having no character styles attached to them, as their character style is applied via the deeper subsystem. (The style list only display styles added by the user, not styles added by the software via settings.)
Attachments
Image of true hyperlink and fake hyperlink.
Image of true hyperlink and fake hyperlink.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
Zizi64
Volunteer
Posts: 11490
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Set relative (dynamic) font size to hyperlinks

Post by Zizi64 »

In the attached image,
Please upload a real (ODF type) sample document. Then we will able to examine your settings.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

To underscore what I believe I stated above and which I have written in the test file here provided:
The point is, as I believe I explained in the post, that no matter what I do, adding a style to an automatically styled piece of text, does not work; you can only manually edit the character (right-click → character → character), which is the exact opposite of what good practice is.
It therefore appears that the following holds true:
  1. You cannot add a character style to an automatically character-styled piece of text.
  2. To edit the look of an automatically character-styled piece of text, one has to manually change the characters’ appearance; this goes against accepted good practice.
  3. Thus, the only way to get an automatically styled set of characters to dynamically change size relative to their text, is to set a percentile font size which adapts to whichever paragraph font size is set.
  4. Doing the above does not work in LibreOffice 7.0.0.3; the relative font size (percentile size) is only set to be a percentage of the main body text.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
JeJe
Volunteer
Posts: 3085
Joined: Wed Mar 09, 2016 2:40 pm

Re: Set relative (dynamic) font size to hyperlinks

Post by JeJe »

I open your file in LibreOffice, move the line out of the way, and select the hyperlink text.
Then I can double click in the styles and formatting character styles tab on any character style and change it to that style.

As a practical way of getting it to look how you want it... why does setting a character style up for your footnotes not suffice?

Using a macro you can automate inserting a hyperlink in a footnote with whatever font or character style you want.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

Yes, I can with no problem at all style some text to look like a hyperlink—that never was the issue—but if that text has the properties of a hyperlink, then it defaults to the standard style for hyperlinks, and no matter which style I apply to it, it will not change. The only way to make it look as intended, is to remove any properties that makes it an actual, clickable hyperlink, then apply the desired secondary style to it to make it match the surrounding text. As noted, the problem then is that it may look like a duck, but it does not quack like a duck (it can’t be clicked like a hyperlink, as it isn’t a hyperlink; it merely is some text that happens to contain the characters of a URL), and so it isn’t a duck (an actual hyperlink).

No, I could go down the silly route of making the hyperlinks have the standard font and be blue and underlined, but that looks like some hideous high-school paper from the early noughties. I would like for the hyperlinks to stand out, but discreetly so, by adding a simple font change that flows with the rest of the text. My question still is the same: How can I make the font size relative to its surrounding text rather than relative to the body text?
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
JeJe
Volunteer
Posts: 3085
Joined: Wed Mar 09, 2016 2:40 pm

Re: Set relative (dynamic) font size to hyperlinks

Post by JeJe »

I do what I suggested above - double click in the styles and formatting to change the character style of the hyperlink text to a new style - and it remains a hyperlink.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

Screenshot, sample, hyperlinks in footnote text
Screenshot, sample, hyperlinks in footnote text
Screenshot, sample, hyperlinks in body text
Screenshot, sample, hyperlinks in body text
Correction: the purple text does not work fine; I forgot to change that. As can be seen, the hyperlink font size is too small.

As the below image demonstrates clearly, changing the style, be that paragraph or character style, will not change the style of any hyperlinks with the properties of a hyperlink. I can always create fake hyperlinks, but if they are clickable, they will not take any additional style formatting. The only option is to manually format the hyperlink and change its formatting to match that of the surrounding text (such as font size). This means that should I make changes to my footnote formatting style, I would have to go and manually edit every single hyperlink in the footnotes, since they had had manual formatting added to them. This is bad practice. My question remains the same: How can I set a relative font size to the hyperlink style which makes the text size of the footnote change relative to whichever environment it is set in?
JeJe
Volunteer
Posts: 3085
Joined: Wed Mar 09, 2016 2:40 pm

Re: Set relative (dynamic) font size to hyperlinks

Post by JeJe »

In the attached document I've changed the hyperlink character style to line numbering - its still a hyperlink. If you set up a character style for the footnote hyperlinks - then changed the footnote style, you'd only have to change the character style too.
Attachments
Test footnote2.odt
(15.54 KiB) Downloaded 190 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Hagar Delest
Moderator
Posts: 33428
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Set relative (dynamic) font size to hyperlinks

Post by Hagar Delest »

I think that it comes from the fact that you cannot apply more than one character style to a text.
There has been a discussion some time ago but can't manage to find it. Maybe there was even a link to an enhancement request.
Note that if your format the text with a character style as you want first and then select the text and apply the hyperlink, then it keeps the desired formatting.
But if you let AOO/LO apply the autoformatting internal style, then it locks the formatting.
IMHO, the best would be to disable the autoformatting of the hyperlinks and then apply the desired custom style to the string before adding the link to that string. Maybe more work at first but you keep the control of the formatting through the proper character styles.

Note: removing the 3 extra fonts +15Mo each would have siginficantly decreased the attachment size!
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

Hagar Delest wrote:I think that it comes from the fact that you cannot apply more than one character style to a text.
There has been a discussion some time ago but can't manage to find it. Maybe there was even a link to an enhancement request.
Note that if your format the text with a character style as you want first and then select the text and apply the hyperlink, then it keeps the desired formatting.
But if you let AOO/LO apply the autoformatting internal style, then it locks the formatting.
IMHO, the best would be to disable the autoformatting of the hyperlinks and then apply the desired custom style to the string before adding the link to that string. Maybe more work at first but you keep the control of the formatting through the proper character styles.

Note: removing the 3 extra fonts +15Mo each would have siginficantly decreased the attachment size!
This is incredibly helpful! You explain what is most likely the cause of the problem (lack of support for multiple style; I remember that discussion, and its solution no longer works with the latest updates) and provide a workaround for it. Thank you very much!
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by CannedMan »

I think there might be a bug with relative sizes. This is a character style set to a percentile of a percentile (the style for the body text is set to 83 % font size, and the style for the footnotes is 85 % of the style for the body text):
Style applied before reopening the file.
Style applied before reopening the file.
Bilde_2022-04-28_194039310.png (4.79 KiB) Viewed 4958 times
When I reopen the file, the characters with the footnote style revert back to full size:
Characters after the file has been reopened.
Characters after the file has been reopened.
Bilde_2022-04-28_194404393.png (5.59 KiB) Viewed 4956 times
Editing the style, the font size is still set to the correct 85 %, but only by changing it (and applying), then reverting it back (and applying) does the style work as intended. Could it be that this is related to the problem with the relative font sizes I use for the URLs?
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
Hagar Delest
Moderator
Posts: 33428
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by Hagar Delest »

I tried with a blank new file, setting the text body to 80% of the default paragraph style, then footnote to 50% based on text body and the relative sizes remain after closing and reopening the file.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by CannedMan »

This was a character style.
Style tree:
  • Character styles
    • IPA [Inherited from: None; Category: Custom styles; Contents: Western text: Noto Sans + 75% + [No language] + normal]
      • IPA, footnotes [Inherited from: IPA; Category: Custom style; Contents: Western text: 85%
[/list]

It was reproducable. Here is my test file, which did exactly the same as described above.

(Sorry about the incorrect formatting; I’ve removed the extra [/list] twice, but it won’t stick.
Attachments
Test footnote IPA.odt
(9.31 KiB) Downloaded 185 times
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
Hagar Delest
Moderator
Posts: 33428
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by Hagar Delest »

Indeed, had missed the fact you were talking about characters styles.
Well, it seems that the character styles work differently than the paragraph styles.
Para styles do cascade the font size relative to the parent setting. However, the character styles seem to refer to the "first" base size and then keep it hard coded. That is, if you change the paragraph style font size, it has no effect on the char style and if you change the font size of a char style, the child style will not be updated as well.
The char style seems to lose the reference to either the paragraph style or its own parent char style.
Maybe worth a bug report, don't know if it is something expected by the ODF.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
Bill
Volunteer
Posts: 8952
Joined: Sat Nov 24, 2007 6:48 am

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by Bill »

AOO 4.1.14 on Ubuntu MATE 22.04
User avatar
Hagar Delest
Moderator
Posts: 33428
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by Hagar Delest »

Thanks Bill, that explains it all.
I've confirmed that the bug was still there (no update since 2019).
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
Bill
Volunteer
Posts: 8952
Joined: Sat Nov 24, 2007 6:48 am

Re: [Workaround] Set relative (dynamic) font size to hyperli

Post by Bill »

Here's a bug in AOO regarding the change in font size when reloading:

Issue 74873 - relative size in character style varies by ratio 1.2 on reload

See Comment 2 in this bug. It appears that when the font size in a character style is set as a percent, Writer uses the font size in the paragraph style as the base font size when the character style is first applied, but ignores the font size in the paragraph style and uses 12 pt as the base font size when the document is reloaded.
AOO 4.1.14 on Ubuntu MATE 22.04
User avatar
CannedMan
Posts: 250
Joined: Wed Aug 04, 2010 12:06 am

Re: Set relative (dynamic) font size to hyperlinks

Post by CannedMan »

Hagar Delest wrote: Tue Apr 26, 2022 7:01 pm IMHO, the best would be to disable the autoformatting of the hyperlinks and then apply the desired custom style to the string before adding the link to that string. Maybe more work at first but you keep the control of the formatting through the proper character styles.
I have followed this procedure, but it does not work (that is, I have deselected the autocorrection options for automatic URL recognition). I paste the URL text into the text, then style it as a footnote hyperlink – all is good. I then select the URL text and press Ctrl + K to create the hyperlink, and paste the URL into the box for the URL. Pressing OK reformats the text using the default style for hyperlinks, ignoring any custom styles. The only option seems to be to not have actual hyperlinks in the footnotes.
As can be seen, the font size is set to the correct size (8.2 points), but the actual size used, is that of the default hyperlink style (which I have formatted to 9.8 points to match the x-height of the main body text).
As can be seen, the font size is set to the correct size (8.2 points), but the actual size used, is that of the default hyperlink style (which I have formatted to 9.8 points to match the x-height of the main body text).
Bilde_2022-05-11_172449914.png (31.97 KiB) Viewed 4001 times
As mentioned previously, not even manually formatting the hyperlink (that is: formatting it by selecting the text, right-click, Character → Character) will change the look of the footnote hyperlink. What I can do, though, is use the dropdown menus available without opening any settings windows. In other words, the solution (workaround) is: select the text, and set any formatting options via the regular editing window, as such:
Editing the character size via the dropdown menu to actually cause change to the text.
Editing the character size via the dropdown menu to actually cause change to the text.
Bilde_2022-05-11_173002341.png (28.04 KiB) Viewed 3999 times
Of course, as we all know, this is bad form. But at the moment the only solution seems to be to use a bad hack instead of following the prescribed method of using styles. What surprises me about this, is that performing the exact same manual editing of the characters via the window menus, is incapable of effecting change, whilst using the main window drop-down menus and buttons is capable of effecting the desired changes.
Note: removing the 3 extra fonts +15Mo each would have siginficantly decreased the attachment size!
Yeah, I’m aware of that. The reason I included the fonts in the file, was to allow whoever was reading the file to view the file correctly, as font choices was so central to my question.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
Hagar Delest
Moderator
Posts: 33428
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Workaround] Set relative (dynamic) font size to hyperlinks

Post by Hagar Delest »

Indeed. I think I had tested my workaround but not so sure now because I see the same as you. Or maybe I had reset the default internet to its parent properties, without the font resizing in my test document (I made some tests from scratch).
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
Post Reply