Skip to content

Commit

Permalink
typst toc
Browse files Browse the repository at this point in the history
  • Loading branch information
wjschne committed Jan 27, 2025
1 parent 9833e33 commit 63a1fa2
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion _extensions/apaquarto/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: My Document in APA Style, Seventh Edition
author: W. Joel Schneider
version: 4.3.9
version: 4.3.10
quarto-required: ">=1.4.549"
contributes:
formats:
Expand Down
10 changes: 10 additions & 0 deletions _extensions/apaquarto/frontmatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,23 @@ return {
if meta["suppress-title-page"] then
body = List:new{}
end

print(PANDOC_WRITER_OPTIONS["table_of_contents"])

if FORMAT:match 'typst' and PANDOC_WRITER_OPTIONS["table_of_contents"] then
body:extend({pandoc.RawBlock('typst', '\n\n#outline(title: [Table of Contents])\n\n')})
body:extend({pandoc.RawBlock('typst', '#pagebreak()\n\n')})
end

if meta.apatitledisplay and not meta["suppress-title-introduction"] then
local firstpageheader = documenttitle:clone()
firstpageheader.identifier = "firstheader"
firstpageheader.classes = {"title", "unnumbered", "unlisted"}
body:extend({firstpageheader})
end




body:extend(doc.blocks)
return pandoc.Pandoc(body, meta)
Expand Down
3 changes: 3 additions & 0 deletions _extensions/apaquarto/typst/typst-show.typ
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ $if(lang)$
$endif$
$if(cols)$
cols: $cols$,
$endif$
$if(toc)$
toc: "true",
$endif$
document,
)
1 change: 1 addition & 0 deletions _extensions/apaquarto/typst/typst-template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ if sys.version.at(1) >= 11 or sys.version.at(0) > 0 {


}

10 changes: 8 additions & 2 deletions changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ engine: knitr
* Full language option support


# Version 4.3.9 (2025-1-26)

- [#109](https://github.com/wjschne/apaquarto/pull/109) Make ORCID have https link instead of http. [Thanks Kilian Sander!](https://github.com/KilianSander)
- added table of contents to apaquarto-typst

# Version 4.3.9 (2024-12-14)

- Removed an unnecessary keyword print command used to debug 4.3.8.
- Made html blockquote text the same color as body text.

# Version 4.3.8 (2024-12-14)

- [#102](https://github.com/wjschne/apaquarto/issues/102) Let `keywords` field be a string instead of an array

# Version 4.3.7 (2024-12-14)

- [#101](https://github.com/wjschne/apaquarto/issues/101) Removed indentation from .docx abstract's first paragraph

# Version 4.3.6 (2024-11-22)
Expand Down Expand Up @@ -78,8 +86,6 @@ engine: knitr

- For apaquarto-typst to run correctly, Typst version 0.11.0 or greater is required [#54](https://github.com/wjschne/apaquarto/issues/54). An error message now prompts the user to update Typst.



# Version 4.0.1 (2024-05-01)

- Improvemements for typst
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ <h2 id="toc-title">On this page</h2>

<ul>
<li><a href="#future-version-wishlist" id="toc-future-version-wishlist" class="nav-link active" data-scroll-target="#future-version-wishlist">Future Version Wishlist</a></li>
<li><a href="#version-4.3.9-2025-1-26" id="toc-version-4.3.9-2025-1-26" class="nav-link" data-scroll-target="#version-4.3.9-2025-1-26">Version 4.3.9 (2025-1-26)</a></li>
<li><a href="#version-4.3.9-2024-12-14" id="toc-version-4.3.9-2024-12-14" class="nav-link" data-scroll-target="#version-4.3.9-2024-12-14">Version 4.3.9 (2024-12-14)</a></li>
<li><a href="#version-4.3.8-2024-12-14" id="toc-version-4.3.8-2024-12-14" class="nav-link" data-scroll-target="#version-4.3.8-2024-12-14">Version 4.3.8 (2024-12-14)</a></li>
<li><a href="#version-4.3.7-2024-12-14" id="toc-version-4.3.7-2024-12-14" class="nav-link" data-scroll-target="#version-4.3.7-2024-12-14">Version 4.3.7 (2024-12-14)</a></li>
Expand Down Expand Up @@ -253,6 +254,13 @@ <h1>Future Version Wishlist</h1>
</ul></li>
</ul>
</section>
<section id="version-4.3.9-2025-1-26" class="level1">
<h1>Version 4.3.9 (2025-1-26)</h1>
<ul>
<li><a href="https://github.com/wjschne/apaquarto/pull/109">#109</a> Make ORCID have https link instead of http. <a href="https://github.com/KilianSander">Thanks Kilian Sander!</a></li>
<li>added table of contents to apaquarto-typst</li>
</ul>
</section>
<section id="version-4.3.9-2024-12-14" class="level1">
<h1>Version 4.3.9 (2024-12-14)</h1>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/writing.html
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ <h1>Tables in Code Chunks</h1>
</figcaption>
<div aria-describedby="tbl-mytable-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<div class="tabwid tabwid_left"><style>.cl-97de114a{}.cl-97d3f35e{font-family:'Times New Roman';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-97d7bc96{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 2;background-color:transparent;}.cl-97d7e004{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(0, 0, 0, 1.00);border-top: 0.75pt solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-97d7e00e{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-97d7e00f{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-97de114a"><thead><tr style="overflow-wrap:break-word;"><th class="cl-97d7e004"><p class="cl-97d7bc96"><span class="cl-97d3f35e">Letters</span></p></th><th class="cl-97d7e004"><p class="cl-97d7bc96"><span class="cl-97d3f35e">Numbers</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-97d7e00e"><p class="cl-97d7bc96"><span class="cl-97d3f35e">A</span></p></td><td class="cl-97d7e00e"><p class="cl-97d7bc96"><span class="cl-97d3f35e">1</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-97d7e00e"><p class="cl-97d7bc96"><span class="cl-97d3f35e">B</span></p></td><td class="cl-97d7e00e"><p class="cl-97d7bc96"><span class="cl-97d3f35e">2</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-97d7e00f"><p class="cl-97d7bc96"><span class="cl-97d3f35e">C</span></p></td><td class="cl-97d7e00f"><p class="cl-97d7bc96"><span class="cl-97d3f35e">3</span></p></td></tr></tbody></table></div>
<div class="tabwid tabwid_left"><style>.cl-a7cc3e66{}.cl-a7c373ee{font-family:'Times New Roman';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-a7c6f5e6{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 2;background-color:transparent;}.cl-a7c71526{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(0, 0, 0, 1.00);border-top: 0.75pt solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a7c71527{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a7c71530{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-a7cc3e66"><thead><tr style="overflow-wrap:break-word;"><th class="cl-a7c71526"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">Letters</span></p></th><th class="cl-a7c71526"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">Numbers</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-a7c71527"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">A</span></p></td><td class="cl-a7c71527"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">1</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-a7c71527"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">B</span></p></td><td class="cl-a7c71527"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">2</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-a7c71530"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">C</span></p></td><td class="cl-a7c71530"><p class="cl-a7c6f5e6"><span class="cl-a7c373ee">3</span></p></td></tr></tbody></table></div>
</div>
</div>
</figure>
Expand Down
File renamed without changes
3 changes: 3 additions & 0 deletions example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ library(ftExtra)
library(knitr)
conflicts_prefer(dplyr::filter, .quiet = TRUE)
conflicts_prefer(flextable::separate_header, .quiet = TRUE)
```

This is my introductory paragraph. The title will be placed above it automatically. *Do not start with an introductory heading* (e.g., "Introduction"). The title acts as your Level 1 heading for the introduction.
Expand Down Expand Up @@ -187,6 +188,7 @@ Which style of creating figures you choose depends on preference and need.

We can make a table the same way as a figure. Generating a table that conforms to APA format in all document formats can be tricky. When the table is simple, the `kable` function from knitr works well. Feel free to experiment with different methods, but I have found that David Gohel's [flextable](https://davidgohel.github.io/flextable/) to be the best option when I need something more complex.


```{r}
#| label: tbl-mytable
#| tbl-cap: The Table Caption
Expand All @@ -196,6 +198,7 @@ tibble(Numbers = seq(1,4), Letters = LETTERS[seq(Numbers)]) %>%
```


To refer to this table in text, use the `@` symbol followed by the reference label like so: As seen in @tbl-mytable, the first few numbers and letters of the alphabet are displayed.

In @tbl-mymarkdowntable, there is an example of a plain markdown table with a note below it.
Expand Down

0 comments on commit 63a1fa2

Please sign in to comment.