## Bug description

Hello! I am using Quarto (version 0.9.531) on Windows 10 (I am running RStudio IDE version 2022.07.2+576), to output a PDF Curriculum Vitae. Everything was going great, until I decided to change the font and style of the section headers. And the logic way to do this in Latex, is by using the `titlesec` package. However, a Latex conflict is happening when I include the `titlesec` package. The resulting error produced by xelatex, when I include the  `titlesec` package is this:
```
compilation failed- error
Argument of \paragraph has an extra }.
<inserted text> 
                \par 
l.1641 \ttl@extract\paragraph
                              

see E:\Users\pedro\Documents\curriculo\titlesec-error.log for more information.
```

I started to research a little about this error, and, by doing some tests, I discovered that the source of the Latex error/conflict happens because of this section of the Latex code that is produced by default by Pandoc/Quarto:

```tex
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
  \let\oldparagraph\paragraph
  \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
  \let\oldsubparagraph\subparagraph
  \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
```

In other words, if I remove this Latex code from `titlesec-error.tex`, and, try to compile the `.tex` file again with xelatex, everything works perfectly, without errors.

If I undestood correctly, looks to me that the Latex conflict is happening because `titlesec` looks for a specific definition of `\paragraph` command. However, with the latex code above, we are redefining the `\paragraph` command to a different version (I might be wrong).

## Reproducible example

If you want to reproduce this error, you can do it by using the `titlesec-error.qmd` and `pdf_config.tex` files, which are exposed below. The `titlesec-error.qmd` file is composed of these lines:

```md
---
title: "Pedro Duarte Faria"
format: 
  pdf:
    keep-tex: true
    documentclass: article
    number-sections: true
    colorlinks: true
    geometry:
      - top=2cm
      - bottom=3cm
      - left=2.5cm
      - right=2.5cm
    include-in-header:
      - pdf_config.tex
      
fontsize: 11pt
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

```

And the `pdf_config.tex` is composed of the following lines:

```tex
\usepackage{titlesec}
\titleformat*{\section}{\Large\bfseries\fontforsection}
```

## More infos about the system and session

My `tmlgr` version is:

```r
system("tlmgr --version")
```
```
tlmgr revision 63068 (2022-04-18 07:58:07 +0200)
tlmgr using installation: C:/Users/pedro/AppData/Roaming/TinyTeX
TeX Live (https://tug.org/texlive) version 2022
```

The basic info about my session:
```r
sessionInfo()
```
```
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8  LC_CTYPE=Portuguese_Brazil.utf8    LC_MONETARY=Portuguese_Brazil.utf8
[4] LC_NUMERIC=C                       LC_TIME=Portuguese_Brazil.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0    tinytex_0.38   xfun_0.30 
```

### Checklist

- [x] 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.
2022-09-30T16:47:11Z
pedropark99
bug
closed
Latex conflict when including the `titlesec` package
https://github.com/quarto-dev/quarto-cli/issues/2686