0

I'm writting a pandoc template inspired on iv054-homework-template. I want something like this:

Example

The code I use is:

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage{titlesec}

\titleformat
{\section} % command
[display] % shape
{\normalfont\bfseries} % format
{}{\vspace{1ex}}
{Question \thesection : \ } % before-code
[\vspace{-0.5ex} \rule{\textwidth}{0.3pt}] % after-code

\begin{document}
\thispagestyle{plain}
\begin{center}
  {\Large $title$ } \\
  $author$ \\
  \today
\end{center}

$body$

\end{document}

but I get this error:

Error producing PDF.
! Undefined control sequence.
l.22 \hypertarget

what happend?

2
  • 1
    The code you post does not produce the reported error. There is no real way of debugging without seeing the actual code, but the error suggests e.g. that hyperref hasn't been loaded.
    – campa
    Commented Nov 5, 2021 at 15:29
  • Please, also provide the markdown document you're using and the command line used to compile.
    – LEo
    Commented Nov 5, 2021 at 16:29

1 Answer 1

0

You just need do add the hyperref package in the preambule.

\usepackage{hyperref}

Here is the complete answer:

I created a file test.tex with the following content:

\documentclass[11pt]{article}
\usepackage{hyperref}
\usepackage[T1]{fontenc}
\usepackage{titlesec}

\titleformat{\section}[display]
  {\normalfont\bfseries}
  {}{20pt}{Question \thesection : \ }[\vspace{-0.5ex} \rule{\textwidth}{0.3pt}]

\begin{document}
\thispagestyle{plain}
\begin{center}
  {\Large $title$ } \\
  $author$ \\
  \today
\end{center}

$body$

\end{document}

and a markdown file test.md with the content:

---
title: Exam Test with Pandoc
author: Leonardo Araujo
date: November 05, 2021
---

# My test
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mi dui, posuere vitae ligula sit amet, ultricies porta mi.

# This is a test
Duis et erat felis. Curabitur dolor diam, sagittis sed pretium at, rhoncus id sapien. Nunc sit amet ullamcorper turpis, vitae euismod nisi.

Then I compiled with

pandoc -N --template=test.tex --variable version=2.0 test.md --pdf-engine=xelatex -o test.pdf

and the result was

enter image description here

1
  • Thank you! It works now
    – Sonya
    Commented Nov 6, 2021 at 2:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .