How do I get paragraphs to follow the indention of Headings?

This forum is for all Flare issues related to styles, stylesheets and XML.

How do I get paragraphs to follow the indention of Headings?

Postby benm_130 on Wed May 29, 2013 8:01 am

I would like to be able to use the "Use TOC depth for heading levels" for my document, but the text following the headings does not indent with the heading.

This is what I end with in my output:

Capture.PNG
You do not have the required permissions to view the files attached to this post.
Last edited by benm_130 on Wed May 29, 2013 9:05 am, edited 1 time in total.
benm_130
Propeller Head
 
Posts: 34
Joined: Thu Aug 18, 2011 7:42 am

Re: How do I get paragraphs to follow the indention of Headings?

Postby whunter on Wed May 29, 2013 8:11 am

That is not what "Use TOC depth for heading levels" does. That setting is used to dynamically adjust the heading levels in your output based on the level in your TOC. For example, the first heading in your top level TOC topics will always be H1, regardless of what it actually is in the file, the first heading in your second level TOC topics will always be H2, and so on.

I'm not aware of any way to dynamically adjust the paragraph text based on heading indentation. You would need to create different styles for the different levels of indentation.
whunter
Sr. Propeller Head
 
Posts: 429
Joined: Thu Mar 12, 2009 4:49 pm
Location: Portland, OR

Re: How do I get paragraphs to follow the indention of Headings?

Postby benm_130 on Wed May 29, 2013 8:51 am

Hmm. Seems like there should be some way to make everything after that heading have the same indentation level as the heading. As it is, I went into the stylesheet and set each heading to indent a little more than the one above it, expecting the ensuing paragraph to follow.
benm_130
Propeller Head
 
Posts: 34
Joined: Thu Aug 18, 2011 7:42 am

Re: How do I get paragraphs to follow the indention of Headings?

Postby LTinker68 on Wed May 29, 2013 9:35 am

No. The cascading part of Cascading Stylesheets deals with parent/child relationships. A heading and a paragraph are sibling tags, not parent/child, so the styles don't cascade (inherit) from each other (they both cascade/inherit from the <body> tag). An example of a parent/child set is an ordered list -- the parent is the <ol> tag and the children tags are the <li> tags. Another example is <td> is a child of <tr> which is a child of <table>.

I don't think a complex selector would help you in this case, because they have limited scopes. For example, you could add a complex selector to the stylesheet that controls how a paragraph behaves when it follows a heading tag, but it would only affect that first paragraph; all subsequent paragraphs would resort to the default paragraph style. (Although I'm not familiar with all complex selector types, so I could be wrong about that.)

What you would need to do is use something like a div that would be used to group all the content after the heading. For instance, you could add div.h2Content to the stylesheet that has margin-left set to 20px or .5 in or whatever. You'd then put your paragraphs and tables inside that div. You could also set up a complex selector that automatically inserts a div with class "h2Content" immediately following an h2 tag so your structure is set up automatically after you add an h2 tag.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
LTinker68
Master Propellus Maximus
 
Posts: 7245
Joined: Thu Feb 16, 2006 9:38 pm

Re: How do I get paragraphs to follow the indention of Headi

Postby IFU on Tue Mar 23, 2021 4:22 pm

Just wondering whether there is any new information on this topic. I've been asked to do just that - dynamically adjust the indent of the body text based on heading indentation or TOC depth - and have not come up with anything. Thanks. Isabelle
IFU
Propeller Head
 
Posts: 29
Joined: Tue Dec 05, 2017 5:28 pm
Location: Vancouver BC

Re: How do I get paragraphs to follow the indention of Headi

Postby doloremipsum on Tue Mar 23, 2021 7:53 pm

I haven't tried this myself, but mayyybe you could use sibling combinators, i.e. the + / ~ symbols. It seems that the + refers to just the sibling directly before, while the ~ refers to all adjacent siblings. So you could do something like this:

Code: Select all
h2 ~ p
{
    margin-left: 6pt;
}


This means that all p's that are siblings of an h2 will have that indentation. There will be more to it than that - you will also need to define the margins for lists, divs, images and anything else you might want to have under your h2.

Alternatively, you could try this:

Code: Select all
h2 + div
{
    margin-left: 6pt;
}


This will make a div that directly follows your h2 have the margin, and in turn anything inside that div will inherit the margin. This might actually be the simpler option, because you won't need to anticipate everything you might put under an h2 and add it to the stylesheet - but you do need to remember to encase everything under every heading in a div. So YMMV!

The benefit of both of these approaches is when the heading level is adjusted (by the TOC), the margins *should* adjust as well with no input from you. I hope!
neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit - sed saepe cum dolor apud multos callidos mutuetur, reduci potest.
doloremipsum
Sr. Propeller Head
 
Posts: 176
Joined: Mon Aug 26, 2019 2:11 pm

Re: How do I get paragraphs to follow the indention of Headi

Postby IFU on Wed Mar 24, 2021 10:59 am

Thank you! Both approaches work beautifully. Isabelle
IFU
Propeller Head
 
Posts: 29
Joined: Tue Dec 05, 2017 5:28 pm
Location: Vancouver BC


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 16 guests