How can I hide and outline if it has no entries to display? I believe I should be able to use #if
and #counter
to make this work (and maybe #context
), but I have not wrapped my head around how counters work.
I have a template I am using to make documents. The template includes the creation of outlines.
#outline(
title: [Table of Contents],
)
#outline(
title: [List of Figures],
target: figure.where(kind: image),
)
#outline(
title: [List of Tables],
target: figure.where(kind: table),
)
However, if the document does not use any figures or tables, the outline just prints a title with no entries. In this case, I would like the title to not show at all.
TABLE OF CONTENTS
1. XXXX
2. XXXX
LIST OF FIGURES
LIST OF TABLES
I believe I should be able to do something like
#if (context{counter(figure.where(kind: table)).final()} > 0) [
#outline(
title: [List of Tables],
target: figure.where(kind: table),
)
]
But I get this error:
$ typst compile main.typ
error: expected boolean, found content
┌─ main.typ:12:4
│
12 │ #if (context{counter(figure.where(kind: table)).final()} > 0) [
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks!