Leading and justification for index entries in in-dexter

New to typst. How do I ncrease leading and turn off justification in index entries produced by in-dexter?

Hi there,

Welcome to the forum.

Before anything else, I would suggest reviewing your posts prior to submitting them to ensure a basic level of clarity and readability for other users.

Providing a minimal working example will significantly increase the likelihood of receiving helpful responses.

From your description, it appears that you may only need to adjust the leading and justification settings as you would for a standard paragraph. However, I do not personally use that package, so I may be mistaken.

Could you please share a sample of your code, along with the current output and the expected result? That would make it much easier to assist you.

1 Like

Sorry I mistyped my question since my fingers no longer quite work, and couldn’t see the mistyping in the small window provided since also visually challenged.

Anyway, here is my code:
#import “@preview/in-dexter:0.7.2”: *
#show : set text(size: 9pt)
#make-index(title: [Index],
outlined: false,
use-page-counter: true,
use-bang-grouping:true,
entry-casing: x => x),
]

This produces a two column index with justified columns (not clear how to upload the image to this forum) and too large a leading.

I want to get a ragged (unjustified) right column in the index, as customary, and decrease the leading. I tried the following:

#let ragged-surround(column-content) = {
set align(left)
set par(justify: false, hanging-indent: 1em)
column-content
}

then set
//surround:ragged-surround
in the make-index function, which does not work.

The usual way to set the paragraph leading does not seem to work, and I also tried
/#show index.entry: it => {
set block(spacing: 1em)
it
}
/

Help appreciated.

Thank you for taking the time to clarify your question and specifying the code you are using.

The example you have provided does not make use of the body parameter. So your call to ragged-surround renders nothing.

From the package in-dexter sample-usage document:

The parameter body in the surround function is the content of the resulting index.

I would try something like :

#make-index(
  ...
  surround: body => ragged-surround(body),
  ...
)

You will find that enclosing your code in back ticks ``` helps both readability and enables easier copy/pasting for the users. If you try to copy and paste the code from your original post into your editor, it won’t compile as characters are not being displayed the same way. I suggest you edit your post to add the back ticks.

This is a full Minimum Working Example (MWE) that compiles and that other users (including you) can easily copy and paste:

MWE
#import "@preview/in-dexter:0.7.2": *
#set page(paper: "a7")
#set text(9pt)

#for i in "2Columns" {
  index(i)
}
#index(lorem(12))
#pagebreak()
#index(lorem(10))

#let ragged-surround(column-content) = {
  set align(left)
  set par(justify: false, hanging-indent: 1em)
  column-content
}

= Index
#columns(
  2,
  make-index(
    //title: [Index],
    //outlined: false,
    use-bang-grouping: true,
    use-page-counter: true,
    sort-order: upper,
    //entry-casing: x => x,
    /*  surround: body => {
      set par(first-line-indent: 0pt, spacing: 0.65em, hanging-indent: 1em)
      body
    },*/
    surround: body => ragged-surround(body),
  ),
)

You can just paste a screenshot and it will appear where your cursor is in the text. Or use the image upload button.

Please let us know if the solution works for you.

Thanks a lot! Worked! With some minor tweaks it produces the index in the snip below.

As you see the body is no longer justified, but the page number is still right aligned to the column edge. This is acceptable, but ideally I would like the index as in my book I typeset in LaTeX 20 years ago, where the page numbers are with the body separated by a comma.

I tried adding the following to your mwe. It compiles but has no effect.

  let body = it.body
  let page = it.page
  
  // Format the entry: Body, comma, space, page number
  block(width: 100%[
    #body[, ]#page
  ])
}```

Where exactly did you add those lines? See the docs but page is not intended to be used that way anyway.

By looking at in-dexter’s code, you can achieve what you want by either:

  • modifying the package locally; or
  • submitting a request to the package owner.

If you are willing to modify the package locally, the following code should achieve the desired result:

Replace line 361 with:

    ", " //box(width: 1fr) // Hardcoded inline page numbers