pcall
October 21, 2022, 9:51am
1
Hello,
I'm working on a bookdown::gitbook, and the pages have lots of 4th, 5th, and 6th level headers. The output from these levels looks rough (e.g. 4.2.4.5.1 Fifth Level Header Example
). I'm aware that it's possible to manually suppress the numbering such as in the example below using {-}
:
##### Fifth Level Header Example {-}
However, I would like to suppress the numbering at just the 4th, 5th, and 6th level for the entire book. Is there a way to accomplish this? Thanks!
1 Like
cderv
November 8, 2022, 1:21pm
2
First word of advice - using unnumbered header with Bookdown can mess up the TOC or cross reference in those chapters.
But anyway, to do it I think you would need to use Lua filter with Pandoc for that.
Some info about Lua filter and how to use it with Rmd in our R Markdown Cookbook - you'll find also an example in there.
This book showcases short, practical examples of lesser-known tips and tricks to helps users get the most out of these tools. After reading this book, you will understand how R Markdown documents are transformed from plain text and how you may...
It is not easy at first but it is really powerful to do such thing you are seeking. Your Lua filter would need to do
Process Headers
Check the number of the Header
if 4 5 or 6, then add the unnumbered
attributes on the Header
return back the header.
This will do programmatically as if you added the class to each header.
We've got some more resource about Lua for Pandoc in the new tool Quarto. That could help.
You'll need to do some try and error to create this filter.
Hope it helps
1 Like
pcall
November 15, 2022, 1:55pm
3
Thanks for the recommendation @cderv ! I wasn't aware of Lua--I'll see if I can put together a solution, and add it to my post later on.
1 Like
system
Closed
December 27, 2022, 1:56pm
4
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.