quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.84k stars 312 forks source link

Using qmd files in the front matter #2908

Open dragonstyle opened 1 year ago

dragonstyle commented 1 year ago

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/2872

Originally posted by **fredguth** October 15, 2022 I have been trying to create a Project template for a custom thesis with the Brazilian Academic Standard (ABNT) extending dragonstyle/abnt proof-of-concept. My problem is that I want to let people write "dedication" and "acknowledgment" pages in the frontmatter by adding qmd files. Ideally the _quarto.yml would have a `frontmatter` section similar to `chapters`: ``` yaml ... frontmatter: - frontmatter/dedication.qmd - frontmatter/acknowledgments.qmd - frontmatter/epigraph.qmd chapters: - chapters/introduction.qmd ... ```` The table of contents would be rendered between the frontmatter and the body/chapters section. Extensions like [Quarto Thesis] or [Quarto Titlepages] handle these with `tex` includes and that is how I am dealing with it now. One could also just use metadata and include them in the tex (which I dislike because you end up with a huge yaml file). But I wonder if it would be possible to use the `frontmatter/dedication.qmd` tex output in the `before-body.tex`.
jaredlander commented 1 year ago

This would be very helpful, I need a dedication page before the table of contents.

Likewise, I need "chapters" after the table of contents, but before the main content, whose page numbers should be small roman numerals, such as the preface, forward and acknowledgements.

From a LaTeX point of view, the structure would be very roughly like the following.

So is it just a matter of figuring out how to inject stuff into the Quarto LaTeX template between the \mainmatter and \frontmatter slugs? But then how do you accomplish this for html output?

\begin{document}
\frontmatter

Publisher content here such as \copyright, notes, ISBN info.
\clearpage

Dedication text
\clearpage

\tableofcontents
\clearpage

Forward
Information about the book and author

\clearpage

Acknowledgements
A lot of text thanking people...

\mainmatter

\chapter{First Chapter}
Content of first chapter

\chapter{Second Chapter}
Content of second chapter

\appendix
\chapter{An Appendix}
Appendix content here

\backmatter
\cleardoublepage
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\cleardoublepage
\addcontentsline{toc}{chapter}{\listtablename}
\listoftables
\cleardoublepage

\printindex

\end{document}
dragonstyle commented 1 year ago

Unfortunately this isn't going to make it into the 1.3 release as we're beginning the stabilization process for it soon. I will take a look once again in 1.4.

liyongg commented 1 year ago

Is this possible for docx output as well? I also feel like this will have some side-effects or is at least related to #4024

danieltomasz commented 1 year ago

This option would be really useful, instead of relying on hacks

jaredlander commented 1 year ago

@danieltomasz what hacks are you using? At this point I'll resort to them.

danieltomasz commented 1 year ago

@jaredlander

The simplest is to include something like this

format:
  pdf:
    template-partials:
        - before-body.tex

with the `before-body.tex' having example content ( those parts appear before toc)

$if(has-frontmatter)$
\frontmatter
$endif$

$if(title)$
\maketitle
$endif$

\newpage

%----------------------------------------------
%   Abstract
%----------------------------------------------

\begin{center}
\Large{Abstract}
\end{center}

\vspace*{\baselineskip}

This is the Abstract part

%\newpage

%----------------------------------------------
%   Preface
%----------------------------------------------

\begin{center}
\Large{Preface}
\end{center}

\vspace*{\baselineskip}

This is the Preface part

%\newpage

%----------------------------------------------
%   Acknowledgement
%----------------------------------------------

\begin{center}
\Large{Acknowledgement}
\end{center}

\vspace*{\baselineskip}

This is the acknowledgement part

%\newpage

Check also this repository https://github.com/nmfs-opensci/quarto-thesis, here those content can be more modular (separate tex files)

danieltomasz commented 1 year ago

@jaredlander I see you know this already, sorry for false hope

jaredlander commented 1 year ago

Still very helpful @danieltomasz, thanks!

danieltomasz commented 1 year ago

@jaredlander here another looking good example https://github.com/numbats/monash-quarto-thesis/tree/main

jaredlander commented 1 year ago

Thanks!

Guangyao1991 commented 1 year ago

I'm writing doctoral thesis now, when will this function (frontmatter) would be added? I appreciate your answer.

mcanouil commented 1 year ago

Probably not in time for you to use. There is already a huge amount of work ongoing.

cderv commented 1 year ago

@dragonstyle still targeting this for 1.4 or this will need to be postponed ?

dragonstyle commented 1 year ago

There is a chance it would make 1.4 (prob less than 50% but a chance), but if so it is still probably weeks away.

danieltomasz commented 1 year ago

hi @Guangyao1991 I made a hack I just use a hack I treat everything like mainmater, but I put

format:
  pdf:
    include-before-body:
        text: |
           \pagestyle{plain}
           \pagenumbering{roman}

and use

\pagenumbering{arabic}

where my main content starts