## Premise
Hi everyone! I would like to thank the **RStudio** and the **QUARTO** _community_ for being here and for all the amazing tools and support provided.
I am currently trying to write my _Master's degree thesis_ in **QUARTO**. I am absolutely excited about this great piece of software. Nevertheless, there are problems that puzzle me, at least.
<span style="color: red;">**WARNING**</span> :  **_this is going to be a long one_**, but indeed I hope that if solutions are provided to the following doubts and questions it may be of great aid for that part of community interested in the **PDF format** output. 
Just so you know: there is no title-author-date info in the **quarto.YML** header I provide here because I am adding it afterwards with a custom titlepage I wrote in `LaTex`.

### Operating System
Windows 11 Pro (x64) Build 22000

### IDE
**RStudio** 2022.07.2+576 "Spotted Wakerobin" Release (e7373ef832b49b2a9b88162cfe7eac5f22c40b34, 2022-09-06) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

### QUARTO version
(It is the one that comes with RStudio):

```r
quarto_version()
[1] ‘1.1.189’
```


### My `quarto check` output:

```
[>] Checking Quarto installation......OK
      Version: 1.1.189
      Path: C:\Program Files\RStudio\bin\quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.10.6
      Path: C:/Python/Python310/python.exe
      Jupyter: 4.11.1
      Kernels: python3

[>] Checking Jupyter engine render....OK

[>] Checking R installation...........OK
      Version: 4.2.1
      Path: C:/R/R-4.2.1
      LibPaths:
        - C:/R/R-4.2.1/library
      rmarkdown: 2.16

[>] Checking Knitr engine render......OK
```

## Bugs and questions list 

### 1
Specifying the `output-dir:` behaves weirdly. What's odd about it is that in case I changed my mind and wanted back the compiled project .pdf file in the root directory and thence comment or delete this entry out of the **YML** header... it just ignores it and still renders the book to the previously specified output (a subfolder I named **_book**). While formatting the appearence of this document I noticed that sometimes it helped to close and reopen the project to make **YML** options work. Yet unfortunately, this is not the case with regard to the problems I list here. By the way, is there perhaps some such thing as a "_QUARTO-project related cache_" that can be cleared out?

### 2
Even though I entered a `latex-output-dir:` option, specifying a subdirectory i created (**_tex-docs**), only **index.qmd** related files (such as **index.tex**, **index.log**, **index.lof**, etc.) are moved in there after compilation, while having the .tex file of the entire document in the root directory of the project (the main folder).

### 3
Not having set a title in the YML the outpout obtained is a PDF file named after the name of the project's folder itself. One may try to change this behaviour with: `output-file: "a-name"` and `output-ext: pdf`. In my experience they always get ignored.

### 4
Doubt about the ` fig-pos ` option. Instead of the `:` colon, should one use the `=` equal sign as per the example [here in the docs](https://quarto.org/docs/reference/formats/pdf.html#figures)?

### 5
I am letting a ` LaTex ` preamble do geometry and font related jobs, except for the font name itself which I had troubles with setting it via a ` \fontspec{Arial} ` command. Is it better to rely on the corresponding YML options for geometry and font customization, or is it something acceptably interchangeable? 

### 6
I happen to have a doubt about the `linkcolor:` option. #Documentation states that _**[any x11 color](https://quarto.org/docs/reference/formats/pdf.html#colors)** should be available_. Nevertheless, **none of the x11 color names I tried worked**, resulting in a rendering error. Is it my fault? Am I typing them wrong? Is there an officail list for all the x11 colors?

### 7
If, for instance, I'd like to add everything i have in my **.bib** with an explicit  nocite: | @* statement in the **YML** this command adds up entries to the existing ones printed by in-text **references** (quotations to elements of the provided bibliography **.bib** file called by the `@` operator inside main text or in footnotes). The result is that if I **already cited** an author inside the body of my document, passing a `nocite: @*` command in the **YML** _makes the bibliographic reference to the **same author appear two times**_, also weirdly removing the author's name in the repeated entry with a set of dashes, as may hopefully observe looking at the following snip.

![Screenshot 2022-09-24 201528](https://user-images.githubusercontent.com/108042428/192117751-6b8a09b5-4ffa-4f11-887e-7ffea2a95fd5.png)

### 8
Sometimes the suggestions for **autocompletion** of **YML** metadata entries **do not pop up**, even after closing and reopening the project several times. The only fix happened to be a machine reboot. 

### 9
In different occasions (in my real quarto project which has more content) I managed to change the pagestyle by, for instance, adding a ` \pagestyle{empty} ` or ` \thispagestyle{empty} ` at the beginning of the **.qmd** file containing the section I would have liked to be rendered without headers nor footers nor page numbers. Nonetheless I tried to do this in my **references.qmd** file **but header and footer are still rendered for that section**. I know I added a command in the **preamble.tex** to make headers and footers to be printed on the heading page (as opposite to the default `LaTeX` behaviour), however this woulkd be of no concern at all at the moment I command the page-style to be empty at the beggining of the section (just before the heading entry).

### 10
**QUARTO** "_**Renders on save**_" everytime I save (of course...) even though I toggle off the option ticking out the little box that's on the toolbar of the **Rstudio IDE** file reader for **.qmd** files. That's annoying, and it just happened after I tried reinstalling RStudio to check if this would have fixed the issues I am currently facing... eventually adding another one to the list. _Moreover, I noticed the automatic render on save behaviour when modifying and saving the_ **YML** _header file itself or_ **.tex** _files related to the_ **YML** metadata opened as tab inside the **RStudio IDE**, such as preamble.tex, which by the way do not have that tick box to toggle on or off on their toolbar pane.

### 11
How can one **center a piece of text** for the **.pdf** format? Doing the following still **doesn't** produce a centered output in the pdf. And... yes, I've tried to write this in `CSS` syntax, with absolutely no success at all.

````md
::: {align="center"}
# Introduzione {.unnumbered}
:::
````

### 13
If I'd like to change the way how `number-sections` works, for instance, using roman numerals or restarting the sections' count for a part of my document is it possible to use `tex` code to this right inside (at the beginning of) the corresponding **.qmd** files? Or am I required to make use of **partials** for things like these? 

## Files list

Here are a **_quarto.YML** file and a **preamble.tex** right below. I tried to strip down these two files to the best of my ability (Removed unnecessary entries that would not affect the software's behaviuor, still causing the bugs I discussed above), thence something may semantically make no sense (as language, casue for the italian localization I use a self-made language.yml file which is omitted here). Down below I've written the content of the other relevant files too.


### MY MWE "_quarto.YML"

```YML

project:
  type: book
  #output-dir: _book
  
book:
  chapters:
    - index.qmd
    - 6_risorse.qmd

bibliography: |
  - bibiliografia_lm56.bib
csl: quad_mat_edit.csl
notes-after-punctuation: true
links-as-notes: true
link-citations: true
callout-appearance: default

nocite: |
  @*

format:
  pdf:
    pdf-engine: xelatex
    documentclass: scrbook
    classoption: [12pt,headsepline,footsepline,oneside,headings=small]
    mainfont: ArialMT
    fontsize: 12pt
    monofont: ArialMT
    toc-title: Indice dei contenuti
    toc: true
    number-sections: false
    number-depth: 5
    df-print: kable
    code-line-numbers: true
    fig-align: center
    fig-pos: "H"
    highlight-style: pygments

    output-file: "tesi-lm56"    #This just gets ignored
    output-ext: "pdf"   #This too

    template-partials:
      - toc.tex
      - after-body.tex
    include-in-header: my_YML_LaTeX_preamble.tex
    include-after-body: 
      text: |
        \printindex
    colorlinks: true   
    linkcolor: RoyalBlue4 #Am I typing x11 colors in wrong way? Is there an official list?
    filecolor: RoyalBlue4
    citecolor: RoyalBlue4
    urlcolor: RoyalBlue4
    toccolor: black
    standalone: true
    keep-tex: true
    keep-ipynb: true  
    latex-auto-mk: true
    latex-auto-install: true
    latex-clean: false
    latex-output-dir: _tex-docs

editor: visual
```

### MY MWE "preamble.tex"

```tex
\usepackage[english,main=italian]{babel}
\usepackage[a4paper, twoside, inner=4.5cm, outer=3cm, top=3.5cm, bottom=3.5cm]{geometry}
\usepackage{setspace}
\setstretch{1.5}
\setparsizes{1cm}{1cm}{1cm plus 1fil}
\usepackage[hang]{footmisc}
\renewcommand{\footnotelayout}{\setstretch{1.1}}
\addtolength{\skip\footins}{2pt}
\setlength{\footnotesep}{12pt}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\deffootnote}{\hbox to \z@}{\hbox}{}{\undefined}
\makeatother
\deffootnote[0.6cm]{0em}{1em}{\thefootnotemark.\ }
\RedeclareSectionCommand[tocbeforeskip=2ex plus 2pt minus 1pt]{chapter}
\makeatletter
\renewcommand*{\@pnumwidth}{1em}
\makeatother
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage{makeidx}
\makeindex
\addtocontents{toc}{\protect\thispagestyle{empty}}
\addtocontents{lof}{\protect\thispagestyle{empty}}
\addtocontents{lot}{\protect\thispagestyle{empty}}
\usepackage{afterpage}
\usepackage{scrlayer}
\usepackage{tocloft}
\setlength{\cftchapindent}{-20pt}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{kantlipsum}
\renewcommand*{\chapterpagestyle}{headings}
```

### My toc.tex


```tex
$if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
$endif$
$if(beamer)$
\begin{frame}[allowframebreaks]
$if(toc-title)$
  \frametitle{$toc-title$}
$endif$
  \tableofcontents[hideallsubsections]
\end{frame}
$else$
{
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
$endif$
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$
$endif$

\newpage
```


### My _index.qmd

````md
```{=tex}
\pagestyle{scrheadings}
\pagenumbering{Roman}
```

::: {align="center"}
# Introduzione {.unnumbered}
:::

\kant[1-2].[^1_capitolo-1]

[^1_capitolo-1]: This is an example footnote reference to [@khuri2003] pp. xx
````

**My references.qmd**


````md
\pagenumbering{gobble} #This should remove the `scrheadings`, yet it does not

\pagestyle{empty}

# Risorse {.unnumbered}

::: {#refs}
:::

````


### My "dummy" references .bib file content for this MWE to run

```

@book{khuri_advanced_2003,
	address = {Hoboken, N.J},
	edition = {2nd ed., rev. and expanded},
	series = {Wiley series in probability and statistics},
	title = {Advanced calculus with applications in statistics},
	isbn = {978-0-471-39104-3},
	publisher = {Wiley-Interscience},
	author = {Khuri, André I.},
	year = {2003},
	keywords = {Calculus, Mathematical statistics},
}

@book{ochsner_advanced_2021,
	address = {Cham, Switzerland},
	title = {Advanced {LaTeX} in academia: applications in research and education},
	isbn = {978-3-030-88956-2},
	shorttitle = {Advanced {LaTeX} in academia},
	abstract = {This book contains a comprehensive treatment of advanced LaTeX features. The focus is on the development of high quality documents and presentations, by revealing powerful insights into the LaTeX language. The well-established advantages of the typesetting system LaTeX are the preparation and publication of platform-independent high-quality documents and automatic numbering and cross-referencing of illustrations or references. These can be extended beyond the typical applications, by creating highly dynamic electronic documents. This is commonly performed in connection with the portable document format (PDF), as well as other programming tools which allow the development of extremely flexible electronic documents},
	language = {eng},
	publisher = {Springer},
	author = {Öchsner, Marco and Öchsner, Andreas},
	year = {2021},
	note = {OCLC: 9408012663},
}

@book{lantz_machine_2019,
	address = {Birmingham Mumbai},
	edition = {Third edition},
	title = {Machine learning with {R}: expert techniques for predictive modeling},
	isbn = {978-1-78829-586-4},
	shorttitle = {Machine learning with {R}},
	language = {eng},
	publisher = {Packt Publishing},
	author = {Lantz, Brett},
	year = {2019},
}

@book{khuri2003,
	title = {Advanced calculus with applications in statistics},
	author = {Khuri, {André I.}},
	year = {2003},
	date = {2003},
	publisher = {Wiley-Interscience},
	series = {Wiley series in probability and statistics},
	edition = {2nd ed., rev. and expanded},
	address = {Hoboken, N.J}
}

```

## MANY THANKS YOU TO YOU ALL!

If there is something here that is supposed to work as I am currently experiencing and have showcased in here, please let me know: I'm really not here to assume that something is a bug when infact it is a feature, I just want to understand.



### Checklist

- [x] Include the terminal output of `quarto check`
- [ ] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
dragonstyle
2022-09-24T20:53:40Z
Nicholas-R-Sheriff
bug
v1.4
open
Several Bugs Report for the .pdf format output + doubts
https://github.com/quarto-dev/quarto-cli/issues/2596