![\def 中的换行符](https://linux22.com/image/283393/%5Cdef%20%E4%B8%AD%E7%9A%84%E6%8D%A2%E8%A1%8C%E7%AC%A6.png)
我无法解决我的问题。我有定义:
\def\mfTitle{askdj asldj asdlk jhasd kjhaslkjd asdas}
我想在其中添加一个换行符:
\def\mfTitle{askdj asldj asdlk \newline jhasd kjhaslkjd asdas}
但我收到一个错误:
! 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...
有没有简单的方法可以做到?谢谢
编辑
用法\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\mfadvisor{Dr. Evorubač, ZLe.Sa.}
\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
{\bf Vedúci:} \mfadvisor
\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}
答案1
首先你不应该使用\def
, 但是\newcommand
. 问题是\newline
当传递给 时毫无意义\pdfinfo
。
无论如何,你应该使用\\
而不是\newline
。不过,想法是一样的。
该\ifx\pdfoutput\undefined
测试已过时,不会区分 DVI 或 PDF 输出。请改用包\ifpdf
中的测试ifpdf
。
\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}
这是您的(非常糟糕的)模板的一个可能更好的版本。选择demo
只是graphicx
因为我没有您的徽标;该包epsfig
已过时。也slovak
已过时,最好使用babel
。为了便于参考,我使用了hyperref
,它知道 UTF-8(使用\pdfinfo
您将无法获得正确的结果)。
\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}
\linespread{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\mfadvisor{Dr. Evorubač, ZLe.Sa.}
\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
{\bfseries Vedúci:} \mfadvisor
\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}