How can I add indents to my list of references?

Using typesetter 0.15.2.
Got some issues with list of references.


Optionally system presents list of references justified with no indent (Ex. first three items in the pic)
But I need to construct the list with indent (1.25cm) and justified (Ex. second three ones in the pic. )
By code it looks like that

I know that’s weird but I use #h(1.25 cm) before item.
How can I set it automatically?

The enum function:

Has two parameters that can help you. The indent parameter to change the indent and the body-indent parameter which changes the distance between the numbering and the body.

You can set the default value you want with:

 #set enum(indent: **value**, body-indent: **value**)

Then to enumerate references you can use the enum function explicitely, or you can use the markdown syntax:

+ ref1
+ ref2
+ ref3

Here is an issue
Use the enum function,

#set enum(indent: 1.25cm, body-indent: 0.5em, spacing: 0.5cm)

works perfectly but the rest of the text not justified. Looks like L this


But it takes this

In that case you have to set indent back to 0pt, and use the padding function:

#pad(left: 1.25cm)[
   + ref1
   + ref2
   + ref3
]

Unfortunately


Oh I think I just understood what you want now. This user had the same need, check the thread

1 Like

I tried to use the solution that presented in the link.
No results.

This can be done by using a negative hanging-indent with the itemize package:

#import "@preview/itemize:0.2.0" as el
#show: el.default-enum.with(
  label-width: 1em,
  label-align: left,
  body-indent: 2mm,
  hanging-indent: (-(1em+2mm), -(1em+2mm)*2)
)

+ #lorem(30)
+ #lorem(10)
  + #lorem(20)
  + #lorem(50)

Stanislav, while I think using itemize is simpler, the solution given in the link probably works, you simply forgot a very important line before your list:

#show: correctly-indent-list-and-enum-items

Plus the definition of this function, of course!

Hi @Stanislav, @Simon2, I just formatted a bunch of your code snippets in this thread. Take a look at my edits so that you can apply that formatting yourself in future posts.

Stanislav, I am still not sure what your desired result is. If the latest reply is not what you wanted, please try to describe your goal from scratch. You can use code blocks to sketch the result you want as plain text:

Indentation examples
1. Adam B. Time andd Social Theory. Cambridge: Polity
Press, 1990. 192.


1. Adam B. Time andd Social Theory. Cambridge: Polity
   Press, 1990. 192.


1.   Adam B. Time andd Social Theory. Cambridge: Polity
Press, 1990. 192.



1.   Adam B. Time andd Social Theory. Cambridge: Polity
     Press, 1990. 192.


  1. Adam B. Time andd Social Theory. Cambridge: Polity
Press, 1990. 192.


  1. Adam B. Time andd Social Theory. Cambridge: Polity
  Press, 1990. 192.


  1. Adam B. Time andd Social Theory. Cambridge: Polity
     Press, 1990. 192.

You can get a non-highlighted code block like this:

```txt
...
```

As you can see, you can express different forms of indentation pretty well this way.

I also want to note: the bibliography element may also be relevant here.

1 Like

Hi @ensko, my desired result is this.


With indent 1.25cm. I do it kinda stupid via #h(1.25cm).
@Chaddai_Fouche

#show: correctly-indent-list-and-enum-items

It’s not working in typesetter.

Did you try the itemize solution and does it work for you?

You can change the indentation of the number with the indent parameter to match your 1.25cm, though keep in mind that this indentation will be relative to the body (the start of the text on the first line of an item), not the left margin of the page.

#import "@preview/itemize:0.2.0" as el
#let (label-width, body-indent) = (1em, 1mm)
#let indent = 1.25cm
#let computed-indent = indent - label-width - body-indent
#let compute-hi(n) = {
  let total-label = label-width + body-indent
  return - (total-label + indent * n) 
}
#show: el.default-enum.with(
  label-width: label-width,
  body-indent: body-indent,
  label-align: left,
  indent: (0mm, computed-indent),
  hanging-indent: range(3).map(compute-hi)
)

+ #lorem(30)
+ #lorem(10)
  + #lorem(20)
  + #lorem(50)
    + #lorem(20)
  1000. #lorem(20)
    + #lorem(20)

Which results in what you want from what I understand:


The code in the link was intended to be used like this:

#let correctly-indent-list-and-enum-items(doc) = {
  let first-line-indent() = if type(par.first-line-indent) == dictionary {
    par.first-line-indent.amount
  } else {
    par.first-line-indent
  }

  show list: li => {
    for (i, it) in li.children.enumerate() {
      let nesting = state("list-nesting", 0)
      let indent = context h((nesting.get() + 1) * li.indent)
      let marker = context {
        let n = nesting.get()
        if type(li.marker) == array {
          li.marker.at(calc.rem-euclid(n, li.marker.len()))
        } else if type(li.marker) == content {
          li.marker
        } else {
          li.marker(n)
        }
      }
      let body = {
        nesting.update(x => x + 1)
        it.body + parbreak()
        nesting.update(x => x - 1)
      }
      let content = {
        marker
        h(li.body-indent)
        body
      }
      context pad(left: int(nesting.get() != 0) * li.indent, content)
    }
  }

  show enum: en => {
    let start = if en.start == auto {
      if en.children.first().has("number") {
        if en.reversed { en.children.first().number } else { 1 }
      } else {
        if en.reversed { en.children.len() } else { 1 }
      }
    } else {
      en.start
    }
    let number = start
    for (i, it) in en.children.enumerate() {
      number = if it.has("number") and it.number != auto { 
                it.number 
              } else { 
                number 
              }
      if en.reversed { number = start - i }
      let parents = state("enum-parents", ())
      let indent = context h((parents.get().len() + 1) * en.indent)
      let num = if en.full {
        context numbering(en.numbering, ..parents.get(), number)
      } else {
        numbering(en.numbering, number)
      }
      let max-num = if en.full {
        context numbering(en.numbering, ..parents.get(), en.children.len())
      } else {
        numbering(en.numbering, en.children.len())
      }
      num = context box(
        width: measure(max-num).width,
        align(right, text(overhang: false, num)),
      )
      let body = {
        parents.update(arr => arr + (number,))
        it.body + parbreak()
        parents.update(arr => arr.slice(0, -1))
      }
      if not en.reversed { number += 1 }
      let content = {
        num
        h(en.body-indent)
        body
      }
      context pad(left: int(parents.get().len() > 0) * en.indent, content)
    }
  }
  doc
}

#set list(indent: 1em)
#set enum(indent: 1em, full: true)
#set par(justify: true, first-line-indent: (amount: 1em, all: false))

#show: correctly-indent-list-and-enum-items

#lorem(20)
- #lorem(20)
  - #lorem(20)
    - #lorem(20)

      #lorem(20)
- #lorem(20)
- #lorem(20)
#lorem(20)
+ #lorem(20)
  + #lorem(20)
    + #lorem(20)

      #lorem(20)
+ #lorem(20)
+ #lorem(20)

And result in this (which is not what you wanted indeed):

1 Like

I guess, It’s not my day

… I would really prefer you give us the code (not an image) that’s not working, it would have been way easier to write the correction:

#import "@preview/itemize:0.2.0" as el
#let (label-width, body-indent) = (1em, 1mm)
#let indent = 1cm
#let computed-indent = indent - label-width - body-indent
#let compute-hi(n) = {
  let total-label = label-width + body-indent
  return - (total-label + indent * n) 
}
#show: el.default-enum.with(
  label-width: label-width,
  body-indent: body-indent,
  label-align: left,
  indent: (0mm, computed-indent),
  hanging-indent: range(3).map(compute-hi)
)
  
+ Adam B. Time and Social Theory. Cambridge: Polity Press, 1990. 192 p.
+ Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture \// The Psychological Foundations of Culture / Ed. by Schaller M., Crandall C. S. Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004, P. 335-360.
+ Alexander S. Space, Time, and Deity. Reprinted. New York: The Humanities Press, 1950. Vol. 2. 841 p.
  + Adam B. Time and Social Theory. Cambridge: Polity press, 1990. 192 p.
  + Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture \// The Psychological Foundations of Culture / Ed. by Schaller M., Crandall C. S. Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004, P. 335- 360.
  + Alexander S. Space, Time, and Deity. Reprinted. New York: The Humanities Press, 1950. Vol. 2. 841 p.


And if you really want the first level to not go to the left margin as in your first image (very inconsistent behavior…), you can use this compute-hi instead:

#import "@preview/itemize:0.2.0" as el
#let (label-width, body-indent) = (1em, 1mm)
#let indent = 1cm
#let computed-indent = indent - label-width - body-indent
#let compute-hi(n) = {
  if n == 0 { return 0mm } // <- this
  let total-label = label-width + body-indent
  return - (total-label + indent * n) 
}
#show: el.default-enum.with(
  label-width: label-width,
  body-indent: body-indent,
  label-align: left,
  indent: (0mm, computed-indent),
  hanging-indent: range(3).map(compute-hi)
)
  
+ Adam B. Time and Social Theory. Cambridge: Polity Press, 1990. 192 p.
+ Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture \// The Psychological Foundations of Culture / Ed. by Schaller M., Crandall C. S. Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004, P. 335-360.
+ Alexander S. Space, Time, and Deity. Reprinted. New York: The Humanities Press, 1950. Vol. 2. 841 p.
  + Adam B. Time and Social Theory. Cambridge: Polity press, 1990. 192 p.
  + Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture \// The Psychological Foundations of Culture / Ed. by Schaller M., Crandall C. S. Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004, P. 335- 360.
  + Alexander S. Space, Time, and Deity. Reprinted. New York: The Humanities Press, 1950. Vol. 2. 841 p.

You can replace the + pluses by explicit numbering if you prefer.

1 Like

It is going in some strange way. I didn’t need a multilevel references.
What I needed I can prepare that way


#h(0cm) 1. Adam B. Time and Social Theory / B. Adam, Cambridge: Polity press, 1990. 192 p.

#h(0cm)2. Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture / Edited by M. Schaller, C. S. Crandall, Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004.P. 335–360.\

#h(0cm) 3. Alexander S. Space, Time, and Deity / S. Alexander, Reprinted. New York: The Humanities Press, 1950. 841 p.\

#h(0cm) 4. Allik J. et al. How a National Character is Constructed: Personality Traits Attributed to the Typical Russian \// Cultural-Historical Psychology. 2009. № 1. P. 2–18.\

#h(0cm) 5. Allik J., Realo A. Personality and Culture \// European Journal of Personality. 2009. № 3 (23). P. 149–152.

it fits excellent for me


I just asked about the code, that can do it automatically.

Your first post lacked some clarity as seen by the misunderstanding of both myself and my colleague. Thank you for the code in your last reply.

As suggested in my first post, if you want a very customized list, you just have to use itemize (I’ll suggest you read the documentation if you want to customize your list further):

#import "@preview/itemize:0.2.0" as el
#let indent = 1.25cm
#show: el.paragraph-enum.with(
  indent: indent,
  hanging-indent: -indent
)

#lorem(20)
+ Adam B. Time and Social Theory. Cambridge: Polity Press, 1990. 192 p.
+ Adams G., Markus H. R. Toward a Conception of Culture Suitable for a Social Psychology of Culture \// The Psychological Foundations of Culture / Ed. by Schaller M., Crandall C. S. Mahwah, New Jersey: Lawrence Erlbaum Associates, Inc., 2004, P. 335-360.
+ Alexander S. Space, Time, and Deity. Reprinted. New York: The Humanities Press, 1950. Vol. 2. 841 p.

1 Like