First question on tex.stackexchange after lurking a while, apologies if my form is poor, comments to improve it are welcome.
I am converting a RMarkdown report to LaTeX using knitr
in RStudio with a preamble.tex file.
I have three levels of header using #, ##, ###
. #Header1 is the title of each study and must appear on a separate page, vertically centered (and possibly horizontally left aligned)
LaTeX commands \vspace, \bigskip and \newline as well as spaces (two spaces, \n, and html "br") are systematically ignored by knitr and #Header1 keeps appearing on top of the page. The most that happened was that a blank page was created before the title.
I failed to successfully adapt the code suggested in the remotely compatible questions I found. Attempts with packages titling
and sectsty
also failed because \maketitle
required between \begin{titlingpage}
and \end{titlingpage}
make the document title appear, not the #Header1 that must be included in the TOC.
Attempts with \begin{nscenter}
from this question gave the error "! You can't use `macro parameter character #' in vertical mode. l.206 #"
I was not able to understand this other question about \hfill
.
I have a hunch that something in my preamble overrides the commands, like this one asking to make a new page after each section :
\let\stdsection\section
\renewcommand\section{\newpage\stdsection}
but removing it simply puts the document title an the TOC on the first page. You must have understood by now that my abilities in LaTeX are limited.
I would be grateful for any tip that will help me make header1 vertically centered on a single page, either 1) individually with spaces or \begin{newcommand} + \end{newcommand} or 2) defining in the preamble that any Header1 defined by one # gets vertically centered.
Thanks a lot!
\vspace
ignored) would still be appreciated. I replaced line #2 in the following:\let\stdsection\section \renewcommand\section{\newpage\stdsection}
by:\renewcommand\section{\newpage\vspace*{105pt}\stdsection}
\vspace
was not ignored, but my table of contents was also lowered, so I removed the code altogether.\newpage \clearpage \vspace*{105pt}
before#heading1
. To then separate my TOC from the title page, I disabled it from the YAML and requested it separately.