Body text after latex title page not showing, Rmarkdown - latex

I have successfully been able to add a latex title page to my Rmarkdown file, but the rest of the document doesn't appear. Here is my YAML:
---
output:
pdf_document:
includes:
in_header: title.tex
---
I haven't changed anything else in the Rmarkdown file, it has the standard text starting with: This is an Rmarkdown document etc. I include my title.tex file:
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
\begin{center}
\includegraphics{UCTLogoLong.jpg}
\vspace*{2cm}
\textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
\vspace{0.5cm}
{\LARGE Assignment 1} % SUBTITLE
\vspace{1cm}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
{\LARGE Geostatistics}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
\vspace{1cm}
{\Large NAME } % AUTHOR
{\Large STUDENT NUMBER}
\vspace{1cm}
\includegraphics[width=5cm,height=5cm,keepaspectratio]{statslogo.png}
\vspace{0.2cm}
Department of Statistical Sciences\\
University of Cape Town\\
South Africa\\
\today
\end{center}
\end{titlepage}
\end{document}
I am relatively new to Rmarkdown and have no idea why the standard Rmarkdown text isn't showing in knitted pdf. Any help will be much appreciated.

The problem is that with the \begin{document}...\end{document} you tell latex that it should ignore everything after that. Instead you could issue the content of the title page \AtBeginDocument{...}
title.tex:
\usepackage{graphicx}
\AtBeginDocument{
\begin{titlepage}
\begin{center}
\includegraphics{example-image-duck}
\vspace*{2cm}
\textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
\vspace{0.5cm}
{\LARGE Assignment 1} % SUBTITLE
\vspace{1cm}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
{\LARGE Geostatistics}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
\vspace{1cm}
{\Large John Doe } % AUTHOR
{\Large something}
\vspace{1cm}
\includegraphics[width=5cm,height=5cm,keepaspectratio]{example-image-duck}
\vspace{0.2cm}
Department of Statistical Sciences\\
University of Cape Town\\
South Africa\\
\today
\end{center}
\end{titlepage}
\clearpage
}
Furthermore, I had to remove the empty line in
---
output:
pdf_document:
includes:
in_header: title.tex
---

Related

How to add a subtitle in class article in Latex?

I am writing a report in Latex and my document class must be article. I want to add some additional text under my title but I can't find anything that would correspond to a subtitle command. Does anyone have any suggestions?
\documentclass[11pt,a4paper]{article}
\title {Title}
\author{Name}
\documentclass[11pt,a4paper]{article}
\title {Title}
\author{Name}
\makeatletter
\def\#maketitle{%
\newpage
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \#title \par}%
\vskip 1em%
{\Large Whatever Subtitle you want\par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\#author
\end{tabular}\par}%
\vskip 1em%
{\large \#date}%
\end{center}%
\par
\vskip 1.5em}
\makeatother
\begin{document}
\maketitle
test
\end{document}
Hopefully, I found a very easy and quick solution:
\documentclass[11pt,a4paper]{article}
\title {Title \\[1ex] \large Subtitle}
\author{Name}
\begin{document}
\maketitle
Text.
\end{document}

Insert multiple pages before body with bookdown

I am rendering a pdf book with bookdown and have a manual front page created by frontpage.tex. In my index.Rmd file, i specify the output in the YAML like this:
output:
bookdown::pdf_book:
citation_package: natbib
includes:
before_body: frontpage.tex
in_header: preamble.tex
I would, however, like to have multiple pages before the Table of Contents, such as the quote page, acknowledgements etc. The quote page should not include any header, just the quote itself.
Is this possible by extending the frontpage.tex to multiple pages?
The frontpage.tex looks like this:
\begin{titlepage}
\begin{center}
\Huge
\textbf{Title}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
I tried to add \newpage and continue on a new blank page, then added another \vspace, but the text appears at the top of the page no matter what i do.
You could simply add multiple titlepage environments into the frontpage.tex file, e.g.
{
\pagestyle{empty}
\begin{titlepage}
\begin{center}
\Huge
\textbf{Title}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
\begin{titlepage}
\begin{center}
\Huge
\textbf{AnotherTitle}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
}

How to make the title look like this using maketitle

I tried something like this. But it is not working. I want to put the author object on the left side, the date object on the right side and below them, the title should come and a line should come below the title
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{geometry}
\geometry{
a4paper,
total={180mm,266mm},
left=15mm,
top=14mm,
}
\setlength{\parindent}{0em}
\setlength{\parskip}{1.4em}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\newcommand{\Hrule}{\rule{\linewidth}{0.3mm}}
\makeatletter% since there's an at-sign (#) in the command name
\renewcommand{\#maketitle}{%
%\parindent=0pt% don't indent paragraphs in the title block
{\#author \hfill \#date}
\par
\centering
{\Large \bfseries\textsc{\#title}}
\HRule\par%
}
\makeatother% resets the meaning of the at-sign (#)
\title{
Motivation Letter
}
\author{
Application for Master of Science\\
Computer Science\\
The University of X\\
}
\date{
Sourav Chakraborty\\
x#gmail.com\\
}
Creating this kind of format is just standard latex.
As a starting point that can be largely improved:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{geometry}
\geometry{
a4paper,
total={180mm,266mm},
left=15mm,
top=14mm,
}
\setlength{\parindent}{0em}
\setlength{\parskip}{1.4em}
\begin{document}
~\\[-1cm] % to control vertical position
Application for anything\hfill Paul random\\
School of information\hfill paul.random#gmail.com\\
The university of Nowhere\hfill Appt A...\\
{\centering\textbf{\large Statement of purpose}\\[-0.2cm]} % to have the rule closer
\rule{\textwidth}{1pt} % to control rule width
To Whom It May Concern
Blah blah and so on...
\end{document}

Table of content in latex

Could you help me to solve this problem? How I can separate the table of content, list of figure, list of table in different line in content?
Here, my command
\documentclass[12pt,a4paper,reqno,openbib]{extreport}
\usepackage[a4paper,left=1.60in,right=1.0in,top=1.0in,bottom=1.2in,footskip=0.5in]{geometry}
\usepackage{tocbibind}
%------------------
\usepackage{titletoc}%% http://ctan.org/pkg/titletoc
\titlecontents*{chapter}% <section-type>
[0pt]% <left>
{}% <above-code>
{\bfseries\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
{}% <numberless-entry-format>
{\bfseries\hfill\contentspage}% <filler-page-format>
\begin{document}
\begin{center}
{\Large \bf{Abstract}}
\end{center}
\addcontentsline{toc}{chapter*}{\noindent\text{Abstract}\hspace{12.5cm} }
\bigskip
\begin{center}
{\Large \bf{Abstrak}}
\end{center}
\addcontentsline{toc}{chapter*}{\noindent\text{Abstrak}\hspace{12.8cm}}
\bigskip
\begin{center}
{\Large \bf{Acknowledgment}}
\end{center}
\addcontentsline{toc}{chapter*}{\noindent\text{Acknowledgement}\hspace{11.0cm}}
\bigskip
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
\newpage
%\newpage
\chapter{Chapter 1}
\section{Background of the study}
\chapter{Chapter2}
\section{Background of the study}
\end{document}
The output is:
Please find the attachment showing answers of your query.

Vertically centering a title page

I'm trying to vertically center a title on a custom-sized page with latex. I've written the following code, but for some reason it doesn't center. Could someone please point me to what's wrong with it?
Thanks!
\documentclass{article}
\setlength{\pdfpagewidth}{88.184mm}
\setlength{\pdfpageheight}{113.854mm}
\usepackage[margin=0.5cm, paperwidth=88.184mm, paperheight=113.854mm]{geometry}
\title{[[title]]}
\date{[[date]]}
\author{[[author]]}
\begin{document}
\vspace{\fill}
\maketitle
\vspace{\fill}
\newpage
[[text]]
\end{document}
There are two small bugs in your code.
First, if you want the \vspace to work at the beginning or end of a page, you should use the starred version (\vspace*).
This would work, but \maketitle is a pretty complicated macro, and if used like in your example, it just puts the title at the second page. You can use the titlepage environment, which gives you much more command over how the title page looks like -- including the spacing. For example, you could use the following code:
\documentclass{article}
\setlength{\pdfpagewidth}{88.184mm}
\setlength{\pdfpageheight}{113.854mm}
\usepackage[margin=0.5cm, paperwidth=88.184mm, paperheight=113.854mm]{geometry}
\begin{document}
\begin{titlepage}
\vspace*{\fill}
\begin{center}
{Huge [[title]]}\\[0.5cm]
{Large [[author}\\[0.4cm]
[[date]]
\end{center}
\vspace*{\fill}
\end{titlepage}
[[text]]
\end{document}
\null % Empty line
\nointerlineskip % No skip for prev line
\vfill
\let\snewpage \newpage
\let\newpage \relax
\maketitle
\let \newpage \snewpage
\vfill
\break % page break
If you want to make everything work even with \maketitle put your \vspace*{\fill} inside the first and the last attribute, exp:
\title{**\vspace*{\fill}**[[title]]}
\date{[[date]]}
\author{[[author]]**\vspace*{\fill}**[[}
\begin{document}
\maketitle
\newpage
[[text]]
\end{document}
As in the answer by finrod, \maketitle is a pretty complicated macro, this is why I didn't feel like overwriting it myself (\renewcommand\maketitle{...). Nevertheless, copying, pasting and editing lines 170-201 of article.cls documentclass, I could add a new one to customize (\newcommand\mymaketitle{...) as follows:
\documentclass{article}
\setlength{\pdfpagewidth}{88.184mm}
\setlength{\pdfpageheight}{113.854mm}
\usepackage[margin=0.5cm, paperwidth=88.184mm, paperheight=113.854mm]{geometry}
\title{Title}
\date{Date}
\author{Author}
\makeatletter
\newcommand\mymaketitle{%
\begin{titlepage}
\null\vfil\vskip 40\p#
\begin{center}
{\LARGE \#title \par}
\vskip 2.5em
{\large \lineskip .75em \#author \par}
\vskip 1.5em
{\large \#date \par}
\end{center}\par
\#thanks
\vfil\null
\end{titlepage}
}
\makeatother
\begin{document}
\mymaketitle
Text
\end{document}
The output:

Resources