0

I'm issuing rstudio and bookdown to cross-compile rmarkdown to TeX and make a PDF for my dissertation. I've got everything formatted how I need it, but I'd like an indent to start each of my paragraphs. I've tried the indent: true setting in rmarkdown yaml, and I've tried including a few different variations on this latex command in my preamble: setlength\parindent{24pt}\setlength{\parskip}{0.0pt}. I've also tried moving that command to the last in_header item in the rmarkdown yaml, so I don't think it's an issue with a later pkg overriding it (but maybe I'm wrong).

The resulting pdf: https://github.com/moui72/disStat/blob/master/docs/_main.pdf

Does anyone see what I am doing wrong?

Here is everything before begin{document} in the resulting TeX file.

Links to the full tex file, _site.yml, preamble.tex, and index.Rmd follow the code block. I'll provide a MWE tonight.

\documentclass[11pt,oneside]{book}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
    \setmainfont[]{Georgia}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
% Redefines (sub)paragraphs to behave more like sections
\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

%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}

%%% Change title format to be more compact
\usepackage{titling}

% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}

  \title{}
    \pretitle{\vspace{\droptitle}}
  \posttitle{}
    \author{}
    \preauthor{}\postauthor{}
      \predate{\centering\large\emph}
  \postdate{\par}
    \date{2019-09-10}

\pagenumbering{roman}
\usepackage{xcolor}
\usepackage{array}
\usepackage{eqparbox}
\usepackage{stmaryrd}
\usepackage{pdfpages}
\newcommand{\myframebox}[2][Dia]{\setlength{\fboxsep}{2.5ex}\raisebox{\dimexpr-\height + 1.0ex}{\fcolorbox{black}{white}{\eqmakebox[#1]{\enspace #2\enspace}}}}

\setlength\parindent{24pt}\setlength{\parskip}{0.0pt plus 1.0pt}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}

\usepackage[linguistics]{forest}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{setspace}\doublespacing

Full tex file https://github.com/moui72/disStat/blob/master/docs/_main.tex

_site.yml (used by bookdown for rstudio) https://github.com/moui72/disStat/blob/master/drafts/_site.yml

Preamble.tex https://github.com/moui72/disStat/blob/master/drafts/preamble.tex

Index.Rmd https://github.com/moui72/disStat/blob/master/drafts/index.Rmd

  • 5
    I didn't read all of your code, but the parskip package generally removes paragraph indents. You should create a MWE demonstrating you're problem. That will involve you removing code from your file bit by bit until you have the minimum file that still demonstrates your problem. You will likely find the problem on your own while creating the MWE. – James Sep 11 at 15:37
  • Thank you, @James! As I noted in my Q, I will work on getting a MWE up tonight, but I was hoping that I might get some insight in the mean time, and I have! thanks again – Tyler Peckenpaugh Sep 11 at 16:05
  • 2
    Although it's already been pointed out that the parskip package omits indents, it seems worth mentioning that packages of this sort often delay settings until \AtBeginDocument, so an attempt to override their settings has to be inserted after \begin{document}, otherwise the reversal won't take effect. – barbara beeton Sep 11 at 18:51
  • aha, thank you @barbarabeeton! moving \setlength\parindent{24pt}\setlength{\parskip}{0.0pt plus 1.0pt} so it is just before my first run of prose did the trick =] – Tyler Peckenpaugh Sep 11 at 20:33
2

James and Barbara solved my issue in the comments, with the following points:

  1. The parskip package omits indents

  2. This setting is delayed until \AtBeginDocument, so an attempt to override its settings has to be inserted after \begin{document}, otherwise the reversal won't take effect

The solution was simply to put \setlength\parindent{24pt}\setlength{\parskip}{0.0pt plus 1.0pt} after \begin{document}.

The origin of the issue seems to be that bookdown makes use of the parskip package by default. As noted by Ralf Stuber in the comments of this answer, indent: true should disable parskip. When/if I determine why that didn't work for me, I'll update this answer.

I am posting this answer just in case someone else has the same issue.

  • 1
    Using parskip is indeed the default. However, it is not used with indent: true in the YAML header od index.Rmd. I don't understand why that did not work for you. – Ralf Stubner Sep 12 at 5:58
  • Should it be a top-level setting, or does it belong as a child of e.g., output? I would bet on it being my error. Would it be interesting to you if I were to take the time to figure out what was happening? – Tyler Peckenpaugh Sep 12 at 15:15
  • It should be a top-level setting. It would be interesting to see why that did not work for you. – Ralf Stubner Sep 12 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.