1

I'm trying to get started writing in LaTeX and have the following simple document skeleton:

\documentclass{book}                                                                                             

\begin{document}
\frontmatter

\title{Test Document}
\author{Test Author}
\date{April 2018}
\maketitle

\chapter{Introduction}
intro

\mainmatter
\chapter {Chapter 1}
test

\end{document}

However, documentclass, frontmatter, date, maketitle and mainmatter are all displayed in red and do not work properly. In particular, \documentclass{book} should create a new title page by default but does not. \documentclass[titlepage]{book} and \documentclass[titlepage]{article} do not. newpage and pagebreak do not do anything no matter where I put them. Even copying the example book layout from Wikibooks produces this behavior.

Where have I gone wrong with such a simple document and how do I fix it? I'm using Debian Buster if it matters.

  • 3
    Welcome to TeX.SE! First of all, is this an April joke? If not, how do you compile your snippet? When I compile it with pdflatex, everything seems fine. Nothing is red (no joke ;-). – user121799 Apr 1 '18 at 1:38
  • 4
    Works fine for me. – John Kormylo Apr 1 '18 at 1:38
  • 1
    Works fine for me as well. – Mico Apr 1 '18 at 2:02
  • 3
    @klasdfjasdf I would be very interested where you found the advice to use pandoc test.tex -o test.pdf. You are the second person in a few days reporting issues with this. – Henri Menke Apr 1 '18 at 5:10
  • 4
    I'm voting to close this question as off-topic because pandoc is not a TeX engine. – Henri Menke Apr 6 '18 at 5:15
6

The problem is that you are trying to process the file with pandoc instead of a LaTeX engine. So what you think the workflow is, is

LaTeX ⇒ PDF

but the actual workflow is

LaTeX ⇒ (pandoc internal structure ⇒ LaTeX) ⇒ PDF
        \_____________pandoc______________/

Unfortunately, the pandoc internal structure is not as feature rich as LaTeX and basically everything about your document gets lost in the process.

You can actually see what kind of LaTeX code pandoc emits by using

pandoc test.tex -s -o pandoc-gen.tex

My version of pandoc (1.16.0.2) generates something which has hardly anything in common with the input LaTeX:

\documentclass[]{article}
\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}
\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{hyperref}
\hypersetup{unicode=true,
            pdftitle={Test Document},
            pdfauthor={Test Author},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\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}{0}
% 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

\title{Test Document}
\author{Test Author}
\date{April 2018}

\begin{document}
\maketitle

\section{Introduction}\label{introduction}

intro

\section{Chapter 1}\label{chapter-1}

test

\end{document}
  • 1
    I appreciate your knowledge and explanation, but I think you have to replace "LaTeX" with "pdflatex" just for non-familiar future users of LaTeX. So that they will not get confused when the output will be .dvi instead of .pdf (+1) – koleygr Apr 1 '18 at 8:20

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