MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   Numbered list help (https://www.mobileread.com/forums/showthread.php?t=343299)

Bigo2 11-27-2021 10:41 PM

Numbered list help
 
Hi - sorry if I'm repeating something what was already discussed here...
I created a numbered list in my epub file using negative top margin.

<p class="calibre1">1.</p> /then the text related to the number/
<dd style="margin-top: -18px;">Example text one</dd>

the next list number:

<p class="calibre1">2.</p> /and then the related text/
<dd style="margin-top: -18px;">Example text two</dd>

And so on…

It seems quite simple, works OK... until I open the epub in a reader - the numbers and the related text usually became crooked – vertically misaligned…
How can it be fixed so that the numbers will be always in line with the related text when opened on any device ?

Thanks

jhowell 11-27-2021 10:53 PM

I am curious why you believe that would ever work?

hobnail 11-27-2021 11:04 PM

1 Attachment(s)
Have you tried html's ordered lists? There are also various sites on the web that explain how to make them prettier than they are without any CSS styling.

https://www.w3schools.com/html/html_lists_ordered.asp

Also, rather than use a style= on each tag it's better to use a stylesheet.

https://www.w3schools.com/css/css_howto.asp

With sigil you put it in the Styles folder, then right click on the html files and select your stylesheet to link it and sigil ands the link rel= for you with the proper path.

Bigo2 11-27-2021 11:04 PM

jhowel and hobnail thanks for your answer

But it does work... The negative top margin sends the line up. Only on some devices it became misaligned. Why?
I know how to create numbered list <ol> <li> or <ul> <li>
I was only curious if this can be done - it seem to be possible but...

jhowell 11-27-2021 11:17 PM

Quote:

Originally Posted by Bigo2 (Post 4176166)
Only on some devices it became misaligned. Why?

Again, the question is why you believe that going up exactly 18 pixels is going to bring it into alignment with the prior paragraph?

Bigo2 11-27-2021 11:20 PM

Quote:

Originally Posted by jhowell (Post 4176168)
Again, the question is why you believe that going up exactly 18 pixels is going to bring it into alignment with the prior paragraph?

I just tried until it seemed to be OK in the Book View...
Also the line height can be set

jhowell 11-27-2021 11:36 PM

Quote:

Originally Posted by Bigo2 (Post 4176169)
I just tried until it seemed to be OK in the Book View...
Also the line height can be set

As you found that is just by chance. Also a page break can occur between pairs and that will really mess things up.

Bigo2 11-27-2021 11:50 PM

OK - I thought there was some setting which would guarantee something will be exactly where I want it...

Why was I trying this? I wanted a different fancy font for the number, but I don't know how to do it. This way I described would have been simple.

Basically I don't know how to use different fonts on the same line...

DNSB 11-28-2021 12:32 AM

If you think you've seen misalignment, wait until you have multiple fonts on the same line. Unless they are very carefully matched, fonts can and will have different line heights, ascender and descender values and line spacing. You are likely to find yourself generating text that resembles a ransom note.

Karellen 11-28-2021 01:09 AM

Quote:

Originally Posted by Bigo2 (Post 4176172)
I wanted a different fancy font for the number, but I don't know how to do it.

Do you have a screenshot of what you are trying to achieve?

How different does the font need to be. Can it be as simple as "fantasy" -v- "serif" -v- "sans-serif" -v- "monospace" or are you trying to achieve some pretty striking gothic type text?

Bigo2 11-28-2021 02:00 AM

Karellen thanks -
I don't know how to put the screenshot here - where would I send it?
This concerns a Czech text concerning the Bitcoin B/S.
For the common text I used "Charis SIL Compact" and for the titles I used "GemunuLibre-SemiBold" so the same Gemunu font I also wanted to use for the mumbered lists.
(But I don't have to...)
In the Sigil Book View (yes I'm using an older version with the Book View) as well as in the Calibre E-book viewer this looks 100% - even after AZW3 conversion. But in Kindle the lines are slightly misaligned...
I thought for you code wizards here it would a simple solution...

Karellen 11-28-2021 02:24 AM

In the Editors bar above the text box, in the first row click on the paperclip icon.

If you don't have that icon, underneath the text box click Go Advanced.

Bigo2 11-28-2021 02:31 AM

2 Attachment(s)
Karellen

RbnJrg 11-28-2021 08:05 AM

5 Attachment(s)
Quote:

Originally Posted by Bigo2 (Post 4176155)
How can it be fixed so that the numbers will be always in line with the related text when opened on any device ?

Thanks

What you want is quite easy to get with ordered list... under epub3 :) In theory, the method could work also under epub2 (at least, it will do with webkit) but it won't work with old ereaders based on RMSDK. Here is what you need to do:

1) In your .xhtml file write a normal ordered list (something like):

Code:

  <ol>
    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula.</li>

    <li>Praesent orci dui, pulvinar id convallis a, faucibus non mauris. Donec tellus augue, tempus sed facilisis sed, fringilla quis leo. Mauris vulputate, leo ac facilisis vulputate, enim orci interdum augue, in blandit quam turpis quis dui. Morbi dictum luctus velit nec faucibus.</li>

    <li>Cras vitae tortor purus, ut tincidunt mauris. Sed at velit nisl. Donec eu mauris tortor, interdum condimentum erat. Nam egestas turpis eget nibh laoreet pharetra. Suspendisse a sem eros, ut pulvinar enim. In sed elit eu nulla accumsan tincidunt eget sit amet ipsum. Nullam ut massa rutrum dolor placerat tempor accumsan eget purus.</li>

    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula.</li>
  </ol>

2) In your .css stylesheet write the following:

Code:

ol {
  counter-reset: item;
  margin-left: 0;
  padding-left: 0;
}

li {
  display: block;
  font-family: serif;
  margin-bottom: 0.5em;
  margin-left: 2em;
  text-align: justify;
}

li::before {
  display: inline-block;
  font-family: sans-serif;
  font-weight: bold;
  color: crimson;
  content: counter(item) ") ";
  counter-increment: item;
  width: 2em;
  margin-left: -2em;
}

That's all. As you can see, numbers are with a different font-family than the text and another color and parenthesis. Here you can watch some screenshots:

Attachment 190489Attachment 190490Attachment 190491Attachment 190492

Below you can check the respective epub. It could be possible to get something that also works under epub2 with old ereaders by using the property "display: inline-block" and creating two blocks (for example one block with a width of 5% for numbers and another block with a width of 90% for the text) but it's more complicated (although possible) to write that. For each paragraph you'll need something like:

Code:

<p><span class="block1">1)</span><span class="block2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula.</span></p>

<p><span class="block1">2)</span><span class="block2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula.</span></p>

and

Code:

p  {
  margin: 0 0 1em;
}

.block1 {
  display: inline-block;
  width: 5%;
  vertical-align: top;
  padding-right: 1em;
  text-align: right;
  font-family: sans-serif;
  color: crimson;
}

.block2 {
  display: inline-block;
  width: 90%;
  text-align: justify;
  font-family: serif;
}

Regards

Bigo2 11-28-2021 08:58 AM

RbnJrg - perfect and not complicated! I'm going to play with this...

Thank you very much!


All times are GMT -4. The time now is 08:16 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.