I'm trying to create a macro for generating a title page for manuals. In the simplest case the title should look like
{\huge
\textbf{\productname{} \manualtitle{}}
}
But I would like to have the following rules applied for line-breaks:
- If the whole title fits into one line, do not break it.
- If
manualtitle
fits into one line but not together withproductname
, break between the two. - If
manualtitle
is longer than the line, break afterproductname
and breakmanualtitle
automatically but without hyphens.
I know how to get parts of it to work manually using \newline
and the hyphenrules
and sloppypar
environments, but I can't find a solution that fulfills all three requirements.
Minimal example as requested:
\documentclass[a4paper, 12pt]{report}
\usepackage[paper=a4paper,
left=25mm,
right=25mm,
top=25mm,
bottom=25mm,
showframe]{geometry}
\usepackage[english]{babel}
\setlength\parindent{0pt}
\newcommand{\product}{PRODUCT}
\newcommand{\manualtitle}{User Manual}
\newcommand{\printtitle}{
\vspace{2em}
{\huge
\textbf{\product{} \manualtitle{}}
}
}
\begin{document}
\printtitle
\renewcommand{\manualtitle}{More Important User Manual}
\printtitle
\renewcommand{\manualtitle}{Even Way More Important User Manual}
\printtitle
\end{document}
Desired output:
center
context?flushleft
might be an option~
form of space to keep words together. works quite nicely for titles that are defined as ragged right. (on your last example, i'd use it for "User~Manual
"..)