Non-breaking cross-references

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
Fiona
Sr. Propeller Head
Posts: 118
Joined: Tue Jan 27, 2015 7:44 am
Location: U.K.

Non-breaking cross-references

Post by Fiona »

I've set up an auto numbering system for my tables, in which:

Code: Select all

mc-auto-number-format: 'T: {b}Table {chapnum}-{n+}: {/b}';
This works perfectly in terms of numbering. However, I've got an issue when cross-referencing a table. I've got the following in my css:

Code: Select all

MadCap|xref.table
{
	mc-format: '{paranumonly}';
	page-break-inside: avoid;
	white-space: nowrap;
}
Most of the time this is fine but I have a few situations where the text wraps onto the next line, leaving me with:

blah blah Table 4-
1

or

blah blah Table
4-1

I'd like to eliminate this and force the whole "Table 4-1" to be kept together but I'm not sure how as the I thought the "whitespace: nowrap;" would do that. I can't put non-breaking spaces and dashes into the css (which was my other idea) so I'm a tad stymied.

Any suggestions?
Nita Beck
Senior Propellus Maximus
Posts: 3672
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Non-breaking cross-references

Post by Nita Beck »

I'm going on memory, but here goes.

I tend to use a span to style an autonumber, instead of using the {b} switch, for example, as you have used in your autonumber. Then I'm pretty sure that I can set the white-space: nowrap attribute on the span.

Sorry so short. Hope this points you in the right direction.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Fiona
Sr. Propeller Head
Posts: 118
Joined: Tue Jan 27, 2015 7:44 am
Location: U.K.

Re: Non-breaking cross-references

Post by Fiona »

That's sounds promising Nita but I'm not sure exactly to set that in the css. Using span isn't one of the format options in the auto-numbering format (as {b} is)...can you give me some more info please?

Not sure if it's important, but it's the cross-reference to the number that I want to be non-breaking – the number itself is left-aligned or centre-aligned so doesn't run into the split-across-multiple-lines issue.
Nita Beck
Senior Propellus Maximus
Posts: 3672
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Non-breaking cross-references

Post by Nita Beck »

I've used this technique for years and I'm pretty darned sure that this is how I get my figure numbers and table numbers not to wrap within cross-references. Let's take it a step at a time.

First, let's create a span class that we'll use to style the auto-number of a figure or table title. (I use the same span class for both.) This won't determine the format of the auto-number, but it will determine its appearance (bold, orange, particular font, etc.).

In the CSS, here's the code for that. In my case, I want the auto-number to be bold and regular (rather than, say, bold and italic), but notice that I want it *not to wrap*. That's the important bit for our discussion.

Code: Select all

span.FigureTableNumber
{
	font-weight: bold;
	font-style: normal;
	white-space: nowrap;
}
Next, let's set up the CSS for the figure title with an auto-number. Notice that for the mc-auto-number-format, I don't use any format commands (e.g., {b}) but only auto-number commands (e.g., {chapnum}, {n+}). That's because I want the formatting to come from the span we just set up. (I won't illustrate a table title's auto-number, as it's basically the same.)

Code: Select all

p.FigureTitle
{
	mc-auto-number-format: 'CF:Figure {chapnum}–{n+} ';
	mc-auto-number-class: FigureTableNumber;
}
If we're going to do this through the Stylesheet Editor, start in Simplified View, and edit the p.FigureTitle style's properties. On the Auto-number tab, for Span Class, we can select FigureTableNumber.
Span_class_for_autonumber.png
Hope this helps.
You do not have the required permissions to view the files attached to this post.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
techwrite_BC
Propeller Head
Posts: 11
Joined: Mon Jan 26, 2015 8:43 am
Location: Germany

Re: Non-breaking cross-references

Post by techwrite_BC »

I have the same problem as described by Fiona.
I tried Nita's solution, but somehow it doesn't work properly.
I used the span "NoWrap" to format the style "p.Fig". The span.NoWrap looks like this:

Code: Select all

span.noWrap
{white-space: nowrap;
font:bold;}
As Nita suggested, I linked the span-Style to my p-Style:

Code: Select all

{ p.Fig {mc-auto-number-format: 'CB:Abb. {chapnum}-{n+1}'; mc-auto-number-class:nowrap;}
Now the p.Fig is displayed correctly in bold and does not wrap.
But when I reference the p.Fig with xref.Link which looks like this:

Code: Select all

	MadCap|xref.Link
	{
		mc-format: '{paranum}';
		color: #000000;
			}
}
the bold formatting in the reference is gone, and the line wrap appears again.
Does anyone know where I made a mistake and how I can "transport" the bold/wrap-Information from my p-Style to the xref?
Stefan
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Non-breaking cross-references

Post by NorthEast »

In your paragraph style, for mc-auto-number-class:nowrap; you're using the wrong case for the span class name - it's noWrap, not nowrap.
techwrite_BC
Propeller Head
Posts: 11
Joined: Mon Jan 26, 2015 8:43 am
Location: Germany

Re: Non-breaking cross-references

Post by techwrite_BC »

That's true, but I think the CSS is not case-sensitive here - the p.Fig-Style is formated bold, that means that it does find the span.noWrap. My problem is, where do I tell the xref to display the information from the p.Fig-Style bold and, above all, without word wrapping?
Fiona
Sr. Propeller Head
Posts: 118
Joined: Tue Jan 27, 2015 7:44 am
Location: U.K.

Re: Non-breaking cross-references

Post by Fiona »

I didn't manage to get it working even after Nita's fantastic answer, so I can't help you (but will be thrilled if someone can as then I can fix it in my docs too!)...
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Non-breaking cross-references

Post by NorthEast »

techwrite_BC wrote:That's true, but I think the CSS is not case-sensitive here
CSS class names are case sensitive, so whilst it may work ok in Flare's editor, it's definitely not going to work in web outputs in a browser (and I've not tested PDFs).

I'd also check your CSS is actually valid, as you appear to have an extra { at the start of the p.Fig example, and an extra } at the end of the MadCap|xref.Link example. If you have superfluous braces in your CSS, it's going to go haywire.
techwrite_BC wrote:where do I tell the xref to display the information from the p.Fig-Style bold and, above all, without word wrapping?
You need to add white-space: nowrap; and font-weight:bold; inside MadCap|xref.Link too, if you want to make sure the link text doesn't wrap either.
techwrite_BC
Propeller Head
Posts: 11
Joined: Mon Jan 26, 2015 8:43 am
Location: Germany

Re: Non-breaking cross-references

Post by techwrite_BC »

CSS class names are case sensitive, so whilst it may work ok in Flare's editor, it's definitely not going to work in web outputs in a browser (and I've not tested PDFs).
You're right, I've tested it once again and the HTML-Output is case-sensitive; before I only tested it with PDF. In the PDF output however, the writing is bold, no matter if I write "noWrap" or "nowrap", which I find a bit awkward... So thanks for the hint, these things are always good to know :)
You need to add white-space: nowrap; and font-weight:bold; inside MadCap|xref.Link too, if you want to make sure the link text doesn't wrap either.
I'll try and see how it works. If Flare wraps the line from time to time nevertheless, as Fiona mentioned in her first comment, I thought it might be because Flare interprets the "-" in Table x-x as a command to wrap the line. Once I tried to replace the - by a + for testing, and the word wrap didn't occur anymore.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2650
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Non-breaking cross-references

Post by ChoccieMuffin »

And hopefully you changed "font:bold;" to "font-weight:bold;"
Started as a newbie with Flare 6.1, now using Flare 2024r2.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
SusanK
Jr. Propeller Head
Posts: 1
Joined: Tue Oct 06, 2015 8:10 am

Re: Non-breaking cross-references

Post by SusanK »

Like Fiona, I have been unable to get the suggestions for white-space: nowrap or span.NoWrap settings to fix the orphaned xref numbers in my print (PDF) output. Instead, I've chosen to use the ShortLine elimination settings on the paragraphs and steps (ol) in my procedures. I use the following settings:

Code: Select all

mc-short-line-method: loosen;
	mc-short-line: 5;
	mc-short-line-loosen-end-length: 12;
	mc-short-line-step: 0.1;
	mc-short-line-loosen-maximum: 3;
This works for most orphaned figure numbers (we have many); the extra kerning doesn't dramatically affect the line readability or look odd in the output either.

Occasional orphans still crop up when the figure xref is not at or very near the end of a sentence. The only fix I have for these instances is to keep the kerning, but also add non-breaking spaces just prior to the xref until the number just falls off the end of the line in the Flare Print Layout view. It's a bit awkward, but the PDF output then displays correctly (no online formats planned at the moment).
Post Reply