5

I would like to be able to make a one-time adjustment to the textwidth in order to have a title (or subtitle) appear entirely on one line.

Consider the MWE

\documentclass[12pt]{article}
\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim}
\oddsidemargin -8pt \evensidemargin -15pt \topmargin -25pt
\headheight -5pt \headsep 0pt \textheight 9.5in \textwidth 5.25in
\parskip 10pt

\usepackage{scalefnt} \usepackage{xcolor} \usepackage{lipsum}

\begin{document} \thispagestyle{empty}

\begin{LARGE} \noindent{\textcolor{red}{\textbf{\textsl{Title, Whose Length is Fine}}}}

\vspace{5pt}

\noindent{\textcolor{red}{\textbf{\textsl{Subtitle Whose Length is a Little Too Long}}}} \end{LARGE} \large \vspace*{15pt}

\lipsum[13] \end{document}

with the output

enter image description here

QUESTION: How would I be able to force the statement "Subtitle Whose Length is a Little Too Long" to appear all on the same line---while not affecting the textwidth of 5.25in for the rest of the document?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36

4 Answers4

6

The brute force way to do this is just to place the subtitle in an \mbox. You will then get overfull box warnings, which is probably a good thing, but may be annoying. The command \mbox is based on \makebox which will create boxes of given width, so to suppress warnings you can put the subtitle in \makebox[0pt][l]{...} a box of zero width with the content left aligned:

Sample output

\documentclass[12pt]{article}

\oddsidemargin -8pt \evensidemargin -15pt \topmargin -25pt \headheight -5pt \headsep 0pt \textheight 9.5in \textwidth 5.25in \parskip 10pt

\usepackage{xcolor} \usepackage{lipsum}

\begin{document} \thispagestyle{empty}

\begin{flushleft} \LARGE\color{red}\bfseries\slshape Title, Whose Length is Fine\[1ex] \makebox[0pt][l]{Subtitle Whose Length is a Little Too Long} \end{flushleft}

\large \medskip

\lipsum[13]

\end{document}

I have also tried to simplify the other parts of the mark-up, putting all the title material in a flushleft, so avoiding the \noindent commands, and placing the font selection and color initially.

Andrew Swann
  • 95,762
3

\parbox and \mbox are a bit of overkill for this case and can be challenging to generalize to other contexts.

I would instead, adjust the right margin:

\NewDocumentCommand{\myhead}{ m }
   {%
     {\rightskip=0pt plus 1fil minus 1in % ❶
      \LARGE
      \noindent
      \textcolor{red}{\textbf{\textsl{#1}}}%
      \par
     }%
     \vspace{5pt}%
   }

at ❶ we set \rightskip to allow it to shrink by 1in (this is an arbitrarily chosen amount and you will want to pick something that meets your needs whether you want just a little overhang or you want to be able fill in the whole margin parspace or something else entirely).

Note also, most importantly, that I've wrapped everything up in a new command so that your document isn't filled with arbitrary formatting commands so that this will be easily modifiable on a global business.

Don Hosek
  • 14,078
2

Take advantage of the large right margin by increasing the width of the marginpar area (\marginparwidth). Then insert the long subtitle into a \parbox that extends to this area.

Using a \mbox may seem simpler, but it won't break the line with even longer text and it will overflow the page.

c

\documentclass[12pt]{article}
\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim}
\oddsidemargin -8pt \evensidemargin -15pt \topmargin -25pt
\headheight -5pt \headsep 0pt \textheight 9.5in \textwidth 5.25in
\parskip 10pt

\setlength{\marginparwidth}{120pt} % added <<<<<<<<<<<<<<<<< \usepackage{showframe} % only to show the margins

\usepackage{scalefnt} \usepackage{xcolor} \usepackage{lipsum}

\begin{document}

\thispagestyle{empty}

\begin{LARGE} \noindent{\textcolor{red}{\textbf{\textsl{Title, Whose Length is Fine}}}}

\vspace{5pt}

% use the margin for this long subtitle <<<<<<<<<<<<<<<<

\noindent\parbox{\dimexpr\textwidth+\marginparwidth+\marginparsep\relax}{\textcolor{red}{\bfseries\textsl{Subtitle Whose Length is a Little Too Long and Longer }}}

\noindent\mbox{\textcolor{red}{\bfseries\textsl{Subtitle Whose Length is a Little Too Long and Longer}}}

\end{LARGE} \large \vspace*{15pt}

\lipsum[13]

\end{document}

Simon Dispa
  • 39,141
2

The adjustwidth environment in the changepage package is designed for this.

% longtitleprob.tex  SE 620119
\documentclass[12pt]{article}

\usepackage{changepage} %% PW added

\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim} \oddsidemargin -8pt \evensidemargin -15pt \topmargin -25pt \headheight -5pt \headsep 0pt \textheight 9.5in \textwidth 5.25in \parskip 10pt

\usepackage{scalefnt} \usepackage{xcolor} \usepackage{lipsum}

\begin{document} \thispagestyle{empty}

\begin{LARGE} \noindent{\textcolor{red}{\textbf{\textsl{Title, Whose Length is Fine}}}}

\vspace{5pt}

\begin{adjustwidth}{}{-2cm} %% PW added \noindent{\textcolor{red}{\textbf{\textsl{Subtitle Whose Length is a Little Too Long}}}} \end{adjustwidth} \end{LARGE} \large \vspace*{15pt}

\lipsum[13] \end{document}

enter image description here

The adjustwidth environment takes two length arguments. \begin{adjustwidth}{<left>}{<right>} A positive <left> length will increase the left margin, thus decreasing the textwidth, while a negative length decreases the left margin, thus increasing the textwidth. Similarly for the <right> argument and margin. An empty argument means no adjustment. There is a starred version adjustwidth* which causes the values of the margins to switch between even and odd pages.

Peter Wilson
  • 28,066