Alignment inline graphic

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

Post Reply
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Alignment inline graphic

Unread post by John Johann »

Hi,
One of my projects describing a software application has a lot of inline graphics in, e.g., tutorials. Things like "click on function abc [inline image]".
By default, the images are all vertically aligned with the text baseline meaning that in chm and pdf output, the line-spacing isn't even depending on the size of the icon/image.
As many of the icons/images are difficult to recognise when too small, I can't scale them to the same size as the text.

It's possible to set negative padding in the image properties which makes things a little better in the pdf and chm.
Does anyone use this?
Is there an easy way to do this for multiple images or set it as a percentage of image height?
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Alignment inline graphic

Unread post by Tim Green »

Hi John,

You can't really apply padding for multiple images, or as a standard setting for all images, because it's a property of the individual image. One thing you should also check in a graphics program is whether the images you are using have transparent or white space on their lower edge. Many do, and this can make using them inline difficult.
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.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Alignment inline graphic

Unread post by John Johann »

Hi Tim,
Thanks again.
I had the pleasure of editing most of the images myself when we switched to H&M, so *most* should be without hidden edges unless I wanted it otherwise or had a lapse of concentration ;-).

I was a bit concerned about the negative padding as the Edit Padding properties button doesn't support it -- resets my custom settings to 0.
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Alignment inline graphic

Unread post by Tim Green »

Hi John,

Negative padding isn't really supported, but what you can do is apply subscript to the image. Note that this will only work if it also includes the spaces before and after the image, otherwise it won't catch. :)

Note also that the subscript option makes the font smaller. You can adjust the height by selecting the image along with the spaces before and after and then manually adjusting the font size.
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.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Alignment inline graphic

Unread post by John Johann »

Hi Tim,
I tried out your suggestion.
In PDF it seems better as the inline image doesn't overlap if there is a line break and the image height is "too high".
In CHM, it just got ignored and the inline images were just aligned to the baseline.

I'm also not that sure that I want to put in extra spacing around the inline images for the subscript as that interferes with punctuation. It also didn't seem to make any difference whether it was there or not (in my very limited test).

Would allowing negative padding in the image properties dialogue be something for the Wish list?
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Alignment inline graphic

Unread post by Tim Green »

John Johann wrote: Fri Jun 25, 2021 8:47 am Would allowing negative padding in the image properties dialogue be something for the Wish list?
Negative padding doesn't exist in HTML, only a negative margin, and applying vertical spacing like that to inline elements in HTML is quite tricky. The image would have to be specially declared as an inline block and then adjusted vertically with a negative bottom margin. Since this is only required for some images, it's better to do it yourself:

First give the image a class name in the HTML Class: field (double-click on the image in the HM editor to access). Let's say you're going to call the class "lowdown". You would then apply this class to all images you want to change in this way.

Then add the following CSS to the bottom of the <head> section in the HTML Page Template > Default of your CHM skin:

Code: Select all

<style type="text/css">
   img.lowdown {
   display: inline-block;
   margin-bottom: -3px;
   }
</style>
You can leave out the <stye> tags if there is already a <style> block there that comes after the entry with the <%STYLESHEET%> variable. Then you can just add your code to the end of that style block. You need to adjust the size of the bottom margin, of course. 8)

PS: This will only work like this for images without captions. If they have captions it's much more complicated.
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.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Alignment inline graphic

Unread post by John Johann »

Hi Tim,
Tim Green wrote: Fri Jun 25, 2021 11:44 am Negative padding doesn't exist in HTML, only a negative margin, and applying vertical spacing like that to inline elements in HTML is quite tricky.
I understand that -- just wanted to note that manually setting the padding to something like "0 0 -5 0" in the image properties does actually shift it down in the chm and pdf (even if it is not supposed to).

I added your css in my default stylesheet at the end and seem to be having some inheritance issues. If I add an !important, the margin gets applied -- not sure that's a good idea.

Also, as we seem to like making things more complicated, I don't just have inline images of the same height in the same paragraph and need something like a margin-bottom -10px and a margin-bottom -5px (and possibly more but two would be a cool start).

Simply adding a second img.lowdown10 of course only meant that images tagged with that class were set accordingly but img.lowdown5 class images were all margin 0. That of course depended on the order of the img.lowdown5 and img.lowdown10 in the css.
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Alignment inline graphic

Unread post by Tim Green »

Hi John,

As you note, this is getting overly complicated, and I definitely wouldn't create multiple CSS rules for it. It's fine to add !important, however, to ensure that you won't be overruled by any inline CSS. You will also need to do this if you have set padding, because that applies inline margins that you need to override. Even so, generally speaking, you shouldn't need any of this. If your images don't have any physical space at the bottom, they will be on the baseline. This may not look like the baseline to the human eye, because our minds want it to be somewhere in the middle of the descenders and not on the actual baseline, but that doesn't change the fact of where it is.

As you note, negative padding is applied if you set it (our developers recommended using the subscript option instead when I consulted them, which is why I mentioned it), as a negative margin. When I test that in CHM it works fine, but how well it works is likely to depend on the configuration of the user's system. The Microsoft CHM viewer is ancient and what it can and can't do depend on the IE version the user has installed.
negativepadding.png
On balance, however, I'd recommend using the negative padding. It has the benefit of not disrupting the line height and working in both PDF and HTML. If it doesn't work in CHM on some systems where the users are on obsolete versions of IE and/or Windows that just can't be helped. CHM has been an undead zombie for years now and its final demise is only a matter of time.
You do not have the required permissions to view the files attached to this post.
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.
Post Reply