4

I am currently attempting to write my first Latex document and having some issues with it. There is a weird 3.33333pt at the top of the document, as can be seen in the attached image, and it will not go away despite whatever I do. My code is as follows:

\documentclass{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{tabularx}

\lstset{
    frame=tb,
    language=Java,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\small\ttfamily},
    numbers=none,
    numberstyle=\tiny\color{gray},
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    breaklines=true,
    breakatwhitespace=true,
    tabsize=3,
    moredelim=[il][\textcolor{pgrey}]{$$},
    moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%}
}

%\newcommand{\cmark}{\ding{51}\HS\HS\HS\HS}%

\begin{document}

\def\HS{\hspace{\fontdimen2\font}}\the\fontdimen2\font
\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\definecolor{pred}{rgb}{0.9,0,0}
\definecolor{pgrey}{rgb}{0.46,0.45,0.48}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\title{Paper}
\author{
    Author One\\
    \texttt{author.one@email.com}
    \and
    Author Two\\
    \texttt{author.two@email.com}
}
\date{Docs version: 1.0.0\\\today}

\noindent\makebox[\textwidth]{\includegraphics[width=\paperwidth]{paper_title}}
\maketitle

\newpage

enter image description here

1 Answers1

9

It comes from \the\fontdimen2\font placed immediately after \def\HS{\hspace{\fontdimen2\font}}, so just remove that.

You might also want to use \newcommand instead of \def. The latter will silently overwrite any existing macro, if the macro name (here \HS) was used before. Hence, if you're a bit unlucky/careless with the choice of macro name, you might end up breaking the document some way or another. \newcommand on the other hand checks if the macro is already defined, and throws an error if that is the case. (See also What is the difference between \def and \newcommand? for a lot of info about the difference between the two.)

Unrelated: I'd also move the colour definitions to the preamble, possibly along with \title/\author/\date (see Should I place \title, \author, \date in the preamble or after \begin{document}?).

\documentclass{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{tabularx}

\lstset{
    frame=tb,
    language=Java,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\small\ttfamily},
    numbers=none,
    numberstyle=\tiny\color{gray},
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    breaklines=true,
    breakatwhitespace=true,
    tabsize=3,
    moredelim=[il][\textcolor{pgrey}]{$$},
    moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%}
}

%\newcommand{\cmark}{\ding{51}\HS\HS\HS\HS}%

% \newcommand instead of \def here
\newcommand\HS{\hspace{\fontdimen2\font}}%\the\fontdimen2\font
\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\definecolor{pred}{rgb}{0.9,0,0}
\definecolor{pgrey}{rgb}{0.46,0.45,0.48}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\title{Paper}
\author{
    Author One\\
    \texttt{author.one@email.com}
    \and
    Author Two\\
    \texttt{author.two@email.com}
}
\date{Docs version: 1.0.0\\\today}

\begin{document}
\noindent\makebox[\textwidth]{\includegraphics[width=\paperwidth]{paper_title}}
\maketitle

\newpage


\end{document}
Torbjørn T.
  • 206,688