mvuorre / quarto-apaish

APA7-ish Quarto templates
https://github.com/mvuorre/quarto-apaish/releases/latest/download/example-journal.pdf
Creative Commons Zero v1.0 Universal
18 stars 0 forks source link

APA formatted bibliography #9

Closed mvuorre closed 10 months ago

mvuorre commented 10 months ago

With long documents Typst seems to break with an error related to #emph.

mvuorre commented 10 months ago

This basic example fails

test.qmd:

---
title: APA7ish Quarto Typst PDF template
runninghead: APA7ish

author:
  - name: Norah Jones

bibliography: test.bib
csl: apa.csl
citeproc: true

format:
  quarto-apaish-typst: default
---

[@cohenProblemUnitsCircumstance1999]

# References

::: {#refs}
:::

test.bib:

@article{cohenProblemUnitsCircumstance1999,
  title = {The {{Problem}} of {{Units}} and the {{Circumstance}} for {{POMP}}},
  author = {Cohen, Patricia and Cohen, Jacob and Aiken, Leona S. and West, Stephen G.},
  date = {1999-07-01},
  journaltitle = {Multivariate Behavioral Research},
  volume = {34},
  number = {3},
  pages = {315--346},
  publisher = {{Routledge}},
  issn = {0027-3171},
  doi = {10.1207/S15327906MBR3403_2},
  url = {https://doi.org/10.1207/S15327906MBR3403_2},
  urldate = {2022-07-12},
  abstract = {Many areas of the behavioral sciences have few measures that are accepted as the standard for the operationalization of a construct. One consequence is that there is hardly ever an articulated and understood framework for the units of the measures that are employed. Without meaningful measurement units, theoretical formulations are limited to statements of the direction of an effect or association, or to effects expressed in standardized units. Thus the long term scientific goal of generation of laws expressing the relationships among variables in scale units is greatly hindered. This article reviews alternative methods of scoring a scale. Two recent journal volumes are surveyed with regard to current scoring practices. Alternative methods of scoring are evaluated against seven articulated criteria representing the information conveyed by each in an illustrative example. Converting scores to the percent of maximum possible score (POMP) is shown to provide useful additional information in many cases.}
}
$ quarto render test.qmd
pandoc
  to: typst-citations
  output-file: test.typ
  standalone: true
  default-image-extension: svg
  wrap: none

metadata
  title: APA7ish Quarto Typst PDF template
  runninghead: APA7ish
  author:
    - name: Norah Jones
  bibliography:
    - test.bib
  csl: apa.csl

[typst]: Compiling test.typ to test.pdf...error: expected function, found content
    ┌─ test.typ:270:152
    │
270 │ Cohen, P., Cohen, J., Aiken, L. S., & West, S. G. (1999). The Problem of Units and the Circumstance for POMP. #emph[Multivariate Behavioral Research], #emph[34](3), 315–346. #link("https://doi.org/10.1207/S15327906MBR3403_2")
    │                                                                                                                                                         ^^^^^^^^

However deleting the csl: apa.csl YAML line works:

image

So for now I will change this issue to be about formatting the bibliography (although it is Good Enough™ now IMO.)

mvuorre commented 10 months ago

There's actually a simple fix (f828696):

---
title: APA7ish Quarto Typst PDF template
runninghead: APA7ish

author:
  - name: Norah Jones

format:
  quarto-apaish-typst: default
---

[@cohenProblemUnitsCircumstance1999]

```{=typst} 
#bibliography("test.bib", title: "References", style: "apa")
```

The downside of this is that it doesn't generalize to other Quarto formats (.docx, .html, etc), and so a general (YAML-ish) option should be preferred. Keeping this open but will edit related bits on main.

mvuorre commented 10 months ago

Typst will support csl files natively in the future, closing.