typst-community / glossarium

Glossarium is a simple typst glossary.
MIT License
41 stars 11 forks source link

alignment #80

Open internettechnik opened 3 weeks ago

internettechnik commented 3 weeks ago

unfortunately, the alignment seems to be centered now (0.5.1) which differs from 0.5.0 and cannot be changed / set with set text align directive.

quachpas commented 3 weeks ago

I wouldn't be able to guess what changed. Could you isolate your code for an example? It works on 0.5.0?

quachpas commented 2 weeks ago

@internettechnik ?

RBW1999 commented 1 week ago

Issue

I myb had the same "issue". I didn't check between version, but I also had same weird styling when importing the package.

My issue was user related. The styles that I had applied before were the cause of the bad alignment.

image

The "Cause"

I guess glossarium uses figures and captions under the hood to link and display the entries in the glossar. So your individual styling of figures and captions will take effect on the glossar. As I understand it, this functionality of leaving the styling to the user is intendet ( #60 )

Sadly I wasnt able to reproduce a isolated example in my given time. But I can present and explain my fix.

Solution for my Issue

image

[
    #set figure(placement: none)
    #show figure: set block(width: 100%)
    #show figure.caption: c =>[
      #align(left, [#c.body])
    ]

    #heading([Glossar]) 
    #glossarium.print-glossary(glossar-list)
 ]
  1. I wrapped the styling and the glossar with a content block [ ] so that the style adjustment only affects the glossar.
  2. Setting the figure placement to none keeps the entries from floating to the top or bottom of the page (#set figure(placement: none))
  3. As discussed in this typst-issue-1498 the caption placement depents on the size of the figure. I therefore set the width #show figure: set block(width: 100%)
  4. After setting the width to 100% the align comment works as intendet:
    #show figure.caption: c =>[
      #align(left, [#c.body])
    ]
quachpas commented 1 week ago

If you are styling figure.caption of all kinds, it will affect glossary entries, as they are indeed figure elements. Glad you got it working!