! \reserved@a 的参数有一个额外的 }。\par } 尝试在标题中包含图形时

! \reserved@a 的参数有一个额外的 }。\par } 尝试在标题中包含图形时

我想要author右侧的,所以我使用titling

\documentclass[a4paper, 12pt, oneside]{report}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[width=150mm, top=12.5mm, bottom=25mm]{geometry}
\usepackage{fancyhdr}

\usepackage{titling}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}}
\preauthor{\begin{flushright}}
\postauthor{\par\end{flushright}}

\title{
\includegraphics[scale=0.5]{logo.png}\\
Dipartimento di Ingegneria dell'Informazione e Scienze Matematiche\\
\hfill \break
Masters of Science in Computer and Automation Engineering\\
\hfill \break
Thesis
}
\author{NSV}


\begin{document}

    \maketitle
    \include{chapters/chap1}
    \include{chapters/chap2}
    \include{chapters/chap3}
    \include{chapters/chap4}
    \include{chapters/chap5}

\end{document}

! Argument of \reserved@a has an extra }. <inserted text> \par }但我得到了错误! Paragraph ended before \reserved@a was complete.<to be read again>\par }

如果我删除下面的代码,一切都会正常工作,但我将其放在author中心。

\usepackage{titling}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}}
\preauthor{\begin{flushright}}
\postauthor{\par\end{flushright}}

答案1

只是\protect命令\includegraphics

\documentclass[a4paper, 12pt, oneside]{report}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[width=150mm, top=12.5mm, bottom=25mm]{geometry}
\usepackage{fancyhdr}

\usepackage{titling}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}}
\preauthor{\begin{flushright}}
\postauthor{\par\end{flushright}}

\title{%
\protect\includegraphics[scale=0.5]{example-image}\\
Dipartimento di Ingegneria dell'Informazione e Scienze Matematiche\\[\bigskipamount]
Masters of Science in Computer and Automation Engineering\\[\bigskipamount]
Thesis
}
\author{NSV}


\begin{document}

    \maketitle

\end{document}

\hfill\break还请注意,您应该使用可选的间距命令来代替\\

在此处输入图片描述

答案2

问题是由命令\includegraphics内部引起的\title

您可以\@title通过重新定义来将其包含在内,而不会出现问题\@title

\documentclass[a4paper, 12pt, oneside]{report}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[width=150mm, top=12.5mm, bottom=25mm]{geometry}
\usepackage{fancyhdr}

\usepackage{titling}
\pretitle{\begin{center}\LARGE}
\posttitle{\end{center}}
\preauthor{\begin{flushright}}
\postauthor{\end{flushright}}

\title{
test\hfill test2 \hfill test3
}
\makeatletter
\let\oldtitle\@title
\def\@title{\includegraphics[scale=0.5]{example-image-a}\\\oldtitle}
\makeatother
\author{NSV}


\begin{document}
    \maketitle


\end{document}

输出:

在此处输入图片描述

相关内容