1

I'm trying to adapt an unofficial University of South Florida Latex document class and template file which are available from http://shell.cas.usf.edu/~saito/grad/ into an Rmarkdown template similar to the thesisdown and huskydown packages. After playing with that for a while I was able to get a package that has a custom template (https://github.com/ailich/bulldown) and can be installed with remotes::install_github("ailich/bulldown"). The document will knit, but if I add any headers to the child documents (e.g. # Chapter 1) I get the error "! Undefined control sequence. l.49 \hypertarget". I've included a text file which lists the steps I took to create this R package/template and the edits I had to make to various files. Does anyone know how to fix this issue or why it would occur? I'm not very familiar with Latex so I've had trouble debugging this. I've included an example of the converted .tex document that comes out after clicking "knit" below.

\documentclass[boldheadings,thrmdefs,bbm,ams]{USFDissertation}

%% Set basic information about the disseration
\title{My Dissertation Title}
\author{My Name}
\degree{Doctorate of Philosopy}
\department{Marine Resource Assessment}
\college{College of Marine Science}
\university{}
\majorprofessor{your advisor}{Ph.D.}
\committeemember{committee member 1}{Ph.D.}
\committeemember{committee member 2}{Ph.D.}
\committeemember{committee member 3}{Ph.D}
\committeemember{committee member 4}{Ph.D}
\keywords{keyword1}{keyword2}{keyword3}{keyword4}{keyword5}
\approvaldate{August 5, 2023}
\copyrightdate{2023}

%% Begin the document itself
\begin{document}

%% Make a title page
\maketitle

%% Maybe dedicate it to someone
\begin{dedication}
``My dedication''
\end{dedication}
%% Acknowlege your intellectual debts
\begin{acknowledgment}
``My acknowledgments''
\end{acknowledgment}
%% Insert a table of contents
\tableofcontents

%% Insert a table of tables -- comes before figures in the format.
\listoftables

%% Insert a table of figures
\listoffigures

%% Include an abstract
\begin{abstract}
``Here is my abstract''
\end{abstract}
%% begin the body of the dissertation
\dissertation

\hypertarget{title-of-my-first-chapter}{%
\chapter{Title of my first chapter}\label{title-of-my-first-chapter}}

The first thing

The second thing

The third thing

%% End of dissertation
\end{document}
ailich
  • 100
  • 8
  • can you show your intermediate .tex file? – samcarter_is_at_topanswers.xyz Nov 18 '21 at 14:52
  • @samcarter_is_at_topanswers.xyz, thanks for the suggestion. I just added it to the original post. – ailich Nov 18 '21 at 15:04
  • One problem seems to be that during the conversion to tex, the (nonsense) construct of `\hypertarget{...}{...}` is used. This will require the `hyperref` package, but your class seems to not work well with this package – samcarter_is_at_topanswers.xyz Nov 18 '21 at 15:29
  • 1
    maybe try https://stackoverflow.com/questions/52341046/remove-hypertarget-from-pandoc-latex-output to remove this nonsense code – samcarter_is_at_topanswers.xyz Nov 18 '21 at 15:57
  • @samcarter_is_at_topanswers.xyz, thanks. Do you know where the `pandoc -r markdown-auto_identifiers -w latex test.md -o test.tex` would go? I'm thinking maybe part of this statement could be enclosed in the pandoc_args YAML field in the Rmarkdown document or as the pandoc_args argument in the call to `bookdown::pdf_book` which is currently specified as `pandoc_args = c(pandoc_args, "--top-level-division=chapter")`. – ailich Nov 19 '21 at 15:46
  • @samcarter_is_at_topanswers.xyz, I was able to work out the syntax by a different but related [stackoverflow post](https://stackoverflow.com/questions/47290659/how-can-we-pass-pandoc-args-to-yaml-header-in-rmarkdown). – ailich Nov 27 '21 at 05:23

1 Answers1

1

This can be accomplished with "-r", "markdown-auto_identifiers"

It can be specified in the YAML with

output: 
  bulldown::thesis_pdf:
    pandoc_args: [
      "-r", "markdown-auto_identifiers"
      ]

or in a function like bookdown::pdf_book using the pandoc_args argument

pandoc_args = c(pandoc_args, "--top-level-division=chapter", "-r","markdown-auto_identifiers")

ailich
  • 100
  • 8