0

I'm using Pandoc / Markdown / LaTeX to write lab reports.

I've opted to not deal with multiple intermediate files for my bibliography. So I have to use this to generate my documents:

pandoc --csl=apa.csl lab02.md --bibliography=bibtex.bib -o lab02.pdf

This works alright. The issue is that hanging indent does not work. It's easy to solve this through this code block:

\begingroup
# References
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}

<div id="refs"></div>
\endgroup

Which is how I am citing references. I have to do this because I have a required section after references, otherwise I could simply do # References and have it automatically put everything in, and just do that setlength stuff once right at the end of the doc.

My question is concerning how to create a custom command to do this faster, because I like hanging indent in some other sections too. I want do do this both for ease of use and to learn how to make commands. I am having trouble doing this on my own.

Ideally it'd be something like: \starthang which maps to

\begingroup
# References
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}

And

\endhang which just is an alias for \endgroup

The best I have come up with is this, which doesn't seem to work:

\newenvironment{hang}
{   {\begingroup
    \setlength{\parindent}{-0.2in}
    \setlength{\leftskip}{0.2in}
    \setlength{\parskip}{8pt}
    }
    {
      \endgroup  
    }
}

Any ideas greatly appreciated.

1

One easy solution is to use the hangparas environment from the hanging package:

Pandoc Bibliography example with hangparas

---
header-includes: |
  \usepackage{hanging}
references:
- id: 'abou-el-haj:1983bury'
  type: article-journal
  title: >-
    Bury St Edmunds Abbey Between 1070 and 1124: A History of Property,
    Privilege, and Monastic Art Production
  container-title: Art History
  page: 1-29
  volume: '6'
  issue: '1'
  DOI: 10/gftmwk
  author:
    - family: Abou-El-Haj
      given: Barbara
  issued:
    - year: 1983
      month: 3
- id: 'abou-el-haj:1991audiences'
  type: article-journal
  title: The audiences for the medieval cult of saints
  container-title: Gesta
  page: 3-15
  volume: '30'
  issue: '1'
  DOI: 10/bhjtnp
  author:
    - family: Abou-El-Haj
      given: Barbara
  issued:
    - year: 1991
---

[@abou-el-haj:1983bury; @abou-el-haj:1991audiences]

# References

```{=latex}
\begin{hangparas}{1em}{1}
```

<div id="refs"></div>

```{=latex}
\end{hangparas}
```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.