Page 1 of 1

[Solved - Workaround] Limit length of field text

Posted: Sat Sep 22, 2012 9:11 pm
by Minio
Hi

I would like to place chapter name and page number in page header. I know I can use fields to put variable content there. But problem is, that some headers might be too long, causing them to span across two lines in header. And this is something I would like to avoid.

I am attaching two images: one that displays current behavior and one that displays expected behavior.

Can I even achieve what I expect? If so, how do I do it?
If I could assign some arbitrary variable to chapter (making it change when chapter changes), it would be acceptable solution.

I am using LibreOffice 3.6.1 on Debian testing (amd64), if that matters.

Thanks in advance

Re: Limit length of field text

Posted: Sat Sep 22, 2012 10:38 pm
by acknak
Sorry, there's no simple option to limit the length of a field.

Even if there was, I'm not sure it would work well in a case like this, because truncating (or any other automatic shortening) could change the meaning of the heading text.

Best solution (in my opinion): re-word the headings so they aren't so long. Long headings are usually confusing and less helpful to the reader.

If you really can't do that, then you'll have to create a "running head" that's shorter. You have to use a completely separate field for that, and assign the heading text (or the shorter version) to the new field. I've not actually done that so I can't be 100% sure it will work, but I don't see why it wouldn't work.

Re: Limit length of field text

Posted: Sun Sep 23, 2012 12:14 am
by JohnV
Let's say a long chapter title is necessary. After you type it put you cursor at the beginning and tap Enter. In the new space above type a short title, select it, do Format > Character > Font Effects tab and check Hidden. This short title should now appear in the Header.

You may now what to directly edit the Heading 1 style of the long title paragraph to eliminate the the spacing above the paragraph.

Re: Limit length of field text

Posted: Sun Sep 23, 2012 1:00 am
by Minio
acknak: sorry if this is lame question, but can you point me to some documentation on how to create field that will change along with chapters?
I know that I can put custom fields in document properties, but when I place them in header, they will stay the same in entire document, while, of course, chapter names change. I know I could overcome this by creating different page styles for each chapter, but that's rather inconvenient.
While googling for "running head", I have only found some info on how to create different header/footer on first page. And since I have multiple "first pages" and each must have different headers, that was not very helpful.

JohnV: thanks for tip. I'm afraid it won't work if you automatically number chapter (through Outline numbering window), but that's definitely interesting idea.

I have read somewhere that I could place each chapter in section and then put section name in header. I could do that, but I must be blind and don't see any fields related to sections. Can anyone post exact placement of this field?

As disclaimer: luckily I am not forced to work with such long headers. But they are quite common in scientific journals and I would like to know how to create such effect if I ever have to.

Re: Limit length of field text

Posted: Sun Sep 23, 2012 3:02 am
by acknak
Minio wrote:... can you point me to some documentation on how to create field that will change along with chapters? ...
Sorry, no. I don't know of any documentation on the fields at all. It's pretty much trial and error.

You can try the user guide; I don't think it's covered there, but I could be wrong: http://wiki.services.openoffice.org/wik ... ser_Guides

You can see the main dialog window by Insert > Field > Other

The basic idea would be something like this (as semi-html pseudo code):

<Set field 'Running Head' = "Thanks for the Fish">
<h1>So Long, and Thanks for All the Fish (Hitchhiker's Guide, #4)</h1>

Then, in the header or footer, you insert the 'Running Head' field. Only certain field types are updated in the header/footer; I think a user field will work, but I could be wrong.

You would have to specifically insert a new "set field" field for each heading; shorter headings would have the same text as the heading itself. It would all have to be updated and synchronized manually--not fun.

Re: Limit length of field text

Posted: Sun Sep 23, 2012 10:20 am
by RGB
Minio wrote:JohnV: thanks for tip. I'm afraid it won't work if you automatically number chapter (through Outline numbering window), but that's definitely interesting idea.
You can work around this (sort of) by using two paragraph styles: the proper heading style, hidden as JohnV suggest (I recommend you to use a character style instead of direct formatting) and a "false heading" style. Then, when you apply this false heading style to the visible text, you need to also insert some fields for the chapter number and, of course, work a bit on the tab stops to simulate the real heading, not to mention you'll need to edit the TOC to include the false heading style. Drawback: links will not work on TOC...

Re: Limit length of field text

Posted: Sun Sep 23, 2012 12:30 pm
by Hagar Delest
Here is some example, font color of the short heading (to be hidden) has been set to red so that you see it.
Since the hidden parameter removes the heading from the ToC, set it to white and apply direct formatting to the paragraph to adapt the before/after spacing.
Test.odt
(13.76 KiB) Downloaded 202 times
Please add '[Solved]' at the beginning of your first post title (edit button) if your issue has been fixed.

Re: Limit length of field text

Posted: Sun Sep 23, 2012 1:23 pm
by Minio
acknak wrote:The basic idea would be something like this (as semi-html pseudo code):

<Set field 'Running Head' = "Thanks for the Fish">
<h1>So Long, and Thanks for All the Fish (Hitchhiker's Guide, #4)</h1>

Then, in the header or footer, you insert the 'Running Head' field. Only certain field types are updated in the header/footer; I think a user field will work, but I could be wrong.
If anyone is wondering:
1. Place cursor after heading text
2. Ctrl+F2 to open Fields window
3. In Variables tab, Set variable. Type in name ("runhead") and value. Be sure to check Format as "Text" and check "Invisible" checkbox. This way it won't show up in TOC beside normal text.
4. Place cursor on header/footer, Ctrl+F2. In Variables tab, Show variable, select "runhead" and "Insert".
5. Repeat steps 1-3 for each heading.

RGB, Hagar Delest: thanks for tips and example document.

I think we have found two ways to achieve expected results. I find first (with invisible fileds) more straightforward, but it needs a lot of manual work (perhaps could be automated with macro). Second (with custom heading) is lesser work, but is rather unintuitive.

If anyone has another idea how to solve this problem, I would be more than happy to read it.