Change Font Sizes of Snippet on different topics
Copy link to clipboard
Copied
Is there a way to make the font size different between 2 topics that use the same snippet? I've noticed that typically you need to set the font size for the snippet, but I want to use the same snippet on two different topics, but want the font size to be different.
Copy link to clipboard
Copied
In the CSS editor duplicate your <p> tag and give it a class name such as "large". Set the font size or colour or whatever to what you want. Appply that style to paragraphs where required.
You could use a different CSS but that might not work when you generate your outputs, it depends on how you configure them.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
Thanks Peter. I tried that, but it seems like the tag thats in the snippet overrides the tag that is applied to text in a topic. The font actually appears bigger in the topic when I try that, but the output doesn't show the text as bigger.
Copy link to clipboard
Copied
Actually, the font appears bigger in the topic, but when I exit out of the topic and go back in, it goes back to the original font.
Copy link to clipboard
Copied
Hi,
perhaps I miss something important, but for me the approach with the different <p> tags works.
I use: RH 2022 Update 5.
The snippet I created:
<body>
<p>Here comes some text.</p>
</body>
Then I add this snippet to the same topic twice as inlinesnippets with different styles:
<p class="PreferedParagraphStyleWithBigFont"><span data-conref="../../assets/snippets/NameOfSnippet.hts"> </span></p>
and
<p class="PreferedParagraphStyleWithSmallFont"><span data-conref="../../assets/snippets/NameOfSnippet.hts"> </span></p>
In the HTML output I get the font I as expected and defined by the class styles.
Copy link to clipboard
Copied
I suspect that the OP has font styling of their <p> tag in the snippet, whereas you have left it plain in the snippet (right idea) & applied the styling outside of it.
Copy link to clipboard
Copied
Does this work for you with a pdf output?
Copy link to clipboard
Copied
Yes, I am also using this and have different output variants for the same project: Responsive HTML and PDF.
The idea is the following:
Keep the snippet itself as simple as possible:
<body> <p>Here comes some text.</p> </body>
Define two styles in teh stylesheet that you want to use later, e.g. "
p class="PreferedParagraphStyleWithBigFont"
p class="PreferedParagraphStyleWithSmallFont"
In the topic add the snippet as inlinesnippet (use span tag) and apply the style to the paragraph (in the topic, NOT in the snippet itself)
So topic looks like this:
<p class="PreferedParagraphStyleWithSmallFont"><span data-conref="../../assets/snippets/NameOfSnippet.hts"> </span></p>
and another topic contains:
<p class="PreferedParagraphStyleWithBigFont"><span data-conref="../../assets/snippets/NameOfSnippet.hts"> </span></p>
Then you need to also define the PDF layout style for these new styles.
In your PDF template, open the section stylesheet and modify the content.css in a way it contains the new styles as you wish.
Then generate the output.
Copy link to clipboard
Copied
Ok. This works for me, but I'm realizing that it doesn't like when the snippet has a new line in it. For example, the font on this snippet does not stick when I apply a new line in the snippet. When I try to change this to the new style, it will change intially, but when I save the topic, exit, then go back in the topic. It goes back to normal. It also does not output with the larger font style using pdf output.
However, when I delete the new line, it appears to change to an inline snippet. This will appear in the output with the larger font. Are changing styles of snippets in a topic limited to the snippets being one line? When I say new line, I mean by pressing enter or having bullet points in the snippet.
Copy link to clipboard
Copied
IIRC if you edit a snippet, it opens in its own topic page - you can add or remove lines of headings, etc. provided you keep the HTML clean of styling. That way when you save the snippet and then look at it in the respective topics, it will take on the styling you've told it to use in the span class.
Copy link to clipboard
Copied
I tried to make a PowerPoint describing my dilemma. When I add a new line inside the snippet, it ends up outputting the small font.
Copy link to clipboard
Copied
I'll look at the PowerPoint on the morning. Check the code of the snippet. I suspect a style change.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
Hi,
I had a second thought about your issue. The problem is that inline snippets are not designed to span multiple paragraphs or lists. However, I also have cases where I want to reuse text across several paragraphs and lists while modifying the style. Here are the options you have (at least from what I've found out):
1. If you only need a line break: Keep the snippet simple (no formatting, single <p> tag) and add a line break tag <br/>. This works with PDF.
<p>Here comes the first line even with inline formatting <span class="Emphasize">Hello World!</span>. Then use <br />for the second line</p>
I use this approach if I just need line breaks inside snippets.
2. Create inline snippets per paragraph and concatenate them in the topics with the preferred line breaks, lists, etc.:
I use this approach if I have medium-length text with different styles throughout, such as lists followed by a paragraph, then another list, etc. Each line is a simple snippet, and the "logic" and style assignment happen in the topic. The drawback is that if you have the exact same section multiple times, you have to repeat the part in the topic. Nevertheless, for me, this is a valid approach because the logic does not change too often (it is still maintainable), but I can be sure that at least the content of the text is always the same. More importantly for me, translation is only needed once.
3. If both options above do not work for you and your snippet would not be reused in the same output:
Create one snippet containing all the content you want, apply the styles inside the snippet using manually created styles. Do not use the standard <p> tag, but something like <p class="MySpecialStyle">. Insert the snippet in your topics as a standard snippet (not inline) and modify the stylesheets for your two outputs accordingly. This means that in one output, the stylesheet has a bigger font for "MySpecialStyle," and in the other, a smaller font.
Copy link to clipboard
Copied
Thinking some more, my suggestion would not work as the P tag gets applied. I think you will need two snippets where you set the font in the Snippet Content Properties.
I haven't checked but am pretty sure that will do it.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
Do you think setting up different topic layouts would help? Essentially, I am using one snippet in 2 topics, but the 2 topics are in different documents (different outputs).
Copy link to clipboard
Copied
If they are in different outputs, you can change the CSS in the preset. Would that work for you?
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
It might. How do you change the css in the preset?
Copy link to clipboard
Copied
Apply a Topic Layout with a different CSS applied to it.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
"Topic Layout" doesn't appear for me. I'm using a pdf output, not sure if that makes a difference.
Copy link to clipboard
Copied
In all threads please start with the version of RoboHelp and, where relevant, the type of output.
Look at the content.css in your template.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
Maybe I am completely mistaken, or this has changed in update 5 (I am still on 4), but as far as I know, the snippet takes on the style of the part it is entered into. The snippet itself does not have a certain style (or at least does not need to have one).
So, I have a snippet with a text:
Example text of the snippet.
I can put it into different places of the same or, as you want to, different topics. The text always takes on the style set for the paragraph:
Project file
Code view
Output
Copy link to clipboard
Copied
Exactly, the snippet can have styling applied but does not have to. That's why I suggested two snippets with different font sizes.
________________________________________________________
My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.
Copy link to clipboard
Copied
So I think I got it to work, but I'm noticing that it won't work when it is a "dotted" blue outline (the top snippet), but it will work when it is a more solid blue outline (the bottom snippet). Any idea why there is a difference here? I think I've created the snippets in the same way.
Copy link to clipboard
Copied
The one with the solid blue line is an inline snippet. You can add snippets in two ways: as a <div> tag or as a <span> tag. The <span> tag represents the inline version and inherits the layout from the paragraph it resides in.
<p class="Normal"><span data-conref="../../assets/snippets/MySnippet.hts"> </span></p>
<div data-conref="../../assets/snippets/MySnippet.hts"> </div>
Copy link to clipboard
Copied
Is there a way to apply a style to a div tag? I'm trying to go for the approach of creating a new CSS for topics where I want the larger font, and want the div tag to have a larger font. I don't see it in the standard tags.


-
- 1
- 2