# Newline in \def

I can not solve my problem. I have definition:

\def\mfTitle{askdj asldj asdlk jhasd kjhaslkjd asdas}

and I would like add a newline into it:

\def\mfTitle{askdj asldj asdlk \newline jhasd kjhaslkjd asdas}

but I get an error:

! Undefined control sequence.
\@normalcr ->\let \reserved@e
\relax \let \reserved@f \relax \@ifstar {\let ...
l.20 ...fined\relax\else\pdfinfo{ /Title (\mfTitle
) /Author (\mfAuthor) /Cre...

Is it possible to do it in some easy way? Thanks

EDIT usage of \mfTitle:

\documentclass[12pt]{book}
\usepackage{slovak}
\usepackage{epsfig}
\usepackage{color}
\usepackage{url}
\usepackage[utf8]{inputenc}

\renewcommand\baselinestretch{1.3} % riadkovanie jeden a pol

% pekne pokope definujeme potrebne udaje
\def\mftitle{Názov Práce}
\def\mfthesistype{Diplomová alebo neviem aká práca}
\def\mfauthor{Študent Autor}
\def\mfplacedate{Bratislava, 2008}

\ifx\pdfoutput\undefined\relax\else\pdfinfo{ /Title (\mftitle) /Author (\mfauthor) /Creator (PDFLaTeX) } \fi

\begin{document}

\frontmatter

\thispagestyle{empty}

\noindent
\begin{minipage}{0.20\textwidth}
\includegraphics[width=0.9\textwidth]{komlogo-new}
\end{minipage}
\begin{minipage}{0.79\textwidth}
\begin{center}
\sc asd asdasd \\
asd asd, asd a asd \\
asd asd, asd
\end{center}
\end{minipage}

\vfill
\begin{center}
\begin{minipage}{0.8\textwidth}
\hrule
\bigskip\bigskip
\centerline{\LARGE\sc\mftitle}
\smallskip
\centerline{(\mfthesistype)}
\bigskip
\bigskip
\centerline{\large\sc\mfauthor}
\bigskip\bigskip
\hrule
\end{minipage}
\end{center}
\vfill
\hfill\mfplacedate
\eject % EOP i

\thispagestyle{empty}~\vfill\eject % EOP ii

{~}\vspace{12cm}

\noindent
\begin{minipage}{0.25\textwidth}~\end{minipage}
\begin{minipage}{0.68\textwidth}
Čestne prehlasujem, že som túto diplomovú prácu vypracoval(a) samostatne s použitím citovaných zdrojov.

\bigskip\bigskip

\hfill\hbox to 6cm{\dotfill}
\end{minipage}
\vfill\eject % EOP iii
~\vfill\eject % EOP iv

\tableofcontents

\mainmatter

\input 01intro.tex
\input 02dalej.tex

\backmatter

\nocite{*}
\bibliographystyle{alpha}
\bibliography{literatura}

\end{document}
• Where are you using that command? Inside some other? Regular paragraph? A minimal document compiles right with it. – Sigur Jan 28 '14 at 22:10
• You can try adding \long, but without a MWE including \documentclass and the appropriate packages that reproduces the problem, it is difficult to help, as both versions of \mfTitle as defined above work fine. For reference Why don't we always use \long\def instead of \def?. – Peter Grill Jan 28 '14 at 22:17
• it looks like \newline, although a "robust" command, might be being expanded once too often as it goes through multiple uses. try changing \newline to \protect\newline in the definition. (this is just a guess; not guaranteed.) – barbara beeton Jan 28 '14 at 22:31
• not working :( same error – Dusan Plavak Jan 28 '14 at 22:39

First of all you shouldn't be using \def, but \newcommand. The problem is that \newline makes no sense when passed to \pdfinfo.

In any case you should probably use \\ rather than \newline. The idea is the same, though.

The \ifx\pdfoutput\undefined test is obsolete and won't distinguish between DVI or PDF output. Use \ifpdf from the ifpdf package instead.

\documentclass{article}

\usepackage{ifpdf}

\newcommand\mfTitle{askdj asldj asdlk\\ jhasd kjhaslkjd asdas}
\newcommand\mfAuthor{Dusan Plavak}

\ifpdf
\begingroup
\renewcommand{\\}{}% temporarily disable \\
\pdfinfo{ /Title (\mfTitle) /Author (\mfAuthor) /Creator (PDFLaTeX) }
\endgroup
\fi

\begin{document}
\title{\mfTitle}
\author{\mfAuthor}

\maketitle

\end{document}

Here's a possibly better version of your (really bad) template. The demo option to graphicx is just because I don't have your logo; the package epsfig is obsolete. Also slovak is obsolete and it's better to go with babel. For the info, I used hyperref, which knows UTF-8 (with \pdfinfo you wouldn't get correct results).

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[slovak]{babel}
\usepackage[demo]{graphicx} % the demo option is just because I don't have the logo
\usepackage{color}
\usepackage{url}
\usepackage{ifpdf}
\usepackage{emptypage}
\usepackage{hyperref}

% pekne pokope definujeme potrebne udaje
\def\mftitle{Názov\\ Práce}
\def\mfthesistype{Diplomová alebo neviem aká práca}
\def\mfauthor{Študent Autor}
\def\mfplacedate{Bratislava, 2008}

\ifpdf
\hypersetup{
pdftitle=\mftitle,
pdfauthor=\mfauthor,
pdfcreator=PDFLaTeX,
}
\fi

\begin{document}

\frontmatter

\thispagestyle{empty}

\noindent
\includegraphics[width=0.18\textwidth]{komlogo-new}
\begin{minipage}{0.79\textwidth}
\centering
\sc asd asdasd \\
asd asd, asd a asd \\
asd asd, asd
\end{minipage}

\vfill
\begin{center}
\rule{0.8\textwidth}{0.4pt}

\bigskip\bigskip

{\LARGE\scshape\mftitle\par}

\smallskip

{(\mfthesistype)}

\bigskip\bigskip

{\large\scshape\mfauthor}

\bigskip\bigskip

\rule{0.8\textwidth}{0.4pt}
\end{center}
\vfill
\hfill\mfplacedate
\cleardoublepage % EOP i

\vspace*{12cm}

\noindent
\begin{minipage}{0.68\textwidth}

Čestne prehlasujem, že som túto diplomovú prácu vypracoval(a)
samostatne s použitím citovaných zdrojov.

\bigskip\bigskip

\hspace*{\fill}\makebox[6cm]{\dotfill}
\end{minipage}

\tableofcontents

\mainmatter

% Next lines are commented because I don't have the files
%\input{01intro.tex}
%\input{02dalej.tex}

\backmatter

\nocite{*}
\bibliographystyle{alpha}
\bibliography{literatura}

\end{document}
• thanks, your solution works if I copy-paste it... but when I am trying use it in my template it is not working. I am beginner with tex so do not understand a lot of things... I updated my question with full template.... – Dusan Plavak Jan 28 '14 at 23:13
• @DusanPlavak You have a very bad template, I should say: it's a mixture of LaTeX and Plain with several deprecated commands. – egreg Jan 28 '14 at 23:26
• Uff, ok, it should be a template for bachelor work... So I guess I will try it from other point of view... I discard that template and will try to make my own... Any suggestions from where I can learn it? – Dusan Plavak Jan 28 '14 at 23:28
• @DusanPlavak I provided a better version, that corrects the bad constructions used in what was given to you. I also added a \\ in the title, just to show it works. – egreg Jan 28 '14 at 23:39