Image labelling - pdf and web/eWriter

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

Post Reply
Ga Bowen
Posts: 324
Joined: Mon Jun 27, 2016 5:05 pm

Image labelling - pdf and web/eWriter

Unread post by Ga Bowen »

When producing my pdf documents I currently label images/tables using either the Image Caption or Insert Figure Caption options.

I format each image as "Fig./Table <%NUMBERING1%>-<%HMFIG/TBLCOUNTER%> - ". However, for obvious reasons, when producing for web/eWriter <%NUMBERING1%> just leaves a placeholder.

Do I need to create a separate Webhelp/e-Book conditional for each image? I think I would also need to do a IFNOT for each image reference.

Is there a batch way of doing this or am I manually going to have to go through everything?
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Image labelling - pdf and web/eWriter

Unread post by Tim Green »

Hi Gareth,

I think the problem here is using the NUMBERINGx variable for the chapters in the first place, which restricts you to PDF. It will be a little extra work up front, but instead of using complex conditionals for this I would replace it with a variable setup that will work everywhere. Here are the instructions on this from the documentation, which is on this page:

https://www.helpandmanual.com/help/hm_w ... rsref.html

Including manual chapter references in the counter

In addition to resetting the counter you can also include a manual chapter reference in the counter. There just needs to be a non-numeric character before the actual number you are resetting the counter to:

<%\HMFIGCOUNTER=3-12%> (resets the figure counter to 3-12)
<%\HMFIGCOUNTER=II.1%> (resets the figure counter to II.1)

You only need to make this entry in the first instance of the variable where it is used. After that it will be used automatically until you reset it again. If you are numbering like this you need to include a reset like this in the first figure reference at the beginning of each chapter, of course.

Chapter references in the counters are NOT automatic!

Important:
Note that you can't use automatic chapter references! In the examples above the "3" and "II" references will not increment automatically. You need to change them at the beginning of each chapter when you reset the figure counter.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Ga Bowen
Posts: 324
Joined: Mon Jun 27, 2016 5:05 pm

Re: Image labelling - pdf and web/eWriter

Unread post by Ga Bowen »

OK, nice one. One more thing...

If I use Find & Replace to search for Captions, H+M will only find items in a Edit Figure Caption if selecting Current Topic. Selecting All Topics produces no results.
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Image labelling - pdf and web/eWriter

Unread post by Tim Green »

Ga Bowen wrote: Tue Aug 11, 2020 6:49 pm If I use Find & Replace to search for Captions, H+M will only find items in a Edit Figure Caption if selecting Current Topic. Selecting All Topics produces no results.
There are limitations on search in some XML tags. What you can do in cases like this and for more complex operations is use an external multi-file search and replace Ytool on the source code of your topics, provided your project is saved in the uncompressed HMXP format so that you can access the individual files. You can save to HMXP with Save As... in the File menu. Choose an empty folder to save in (you can add other files and folders to it later if necessary, for example for your images etc).

First you need to create "before" and "after" examples of what you need to do in the HM editor, then look in the XML Source view (tab below the main editor window) to see the XML code you need to find and replace. Then use a multi-file search and replace tool on the topic files in the /Topics sub-folder in your project folder to make the changes.

IMPORTANT: Always make a backup before doing this! Automated global changes are always a little bit risky. ;-)

If you don't have a suitable editor for this here's a list of ones you could use:

Notepad++ (free):
http://notepad-plus-plus.org/

Notepad++ also supports multi-file regular expression searching, if you feel comfortable with that, but it is more limited than PowerGREP but its search and replace is fine for this kind of task. It is also one of the best code editors available, at any price.

PowerGREP:
http://www.powergrep.com/

If you feel comfortable with regular expressions PowerGREP is the best tool available, on any platform and at any price. It is a little pricey, but if you do a lot complex searching in multiple files (also for programming work) it will pay for itself subjectively in a single afternoon. The RegexBuddy tool from the same company (http://www.regexbuddy.com/) is also the best interactive tool available for defining and testing regular expressions, and its documentation is quite literally the best tutorial and introduction to regular expressions available anywhere.

Windows Grep (less expensive and also less powerful than PowerGREP)
http://www.wingrep.com/index.htm
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Ga Bowen
Posts: 324
Joined: Mon Jun 27, 2016 5:05 pm

Re: Image labelling - pdf and web/eWriter

Unread post by Ga Bowen »

That's a massive help.

I managed to do what I wanted using Notepad++.

Many thanks as always, Tim.
Post Reply