2

I have used Tex at a very low level but I now need to try to format something a little more complex than I know how to handle. I have a large set of text files that I need to add a hrule in above and below the title that have set offsets from the title. The spacing between the bottom hrule and the start of the first paragraph needs to be the same across all files.

I have tried using \vspace between each element but the spacing always changes depending on the spacing of the remaining text on that page. Is there a way to set the spacing of the title and hrules to not stretch? Can I force the first paragraph to always start the same distance from the hrule directly below the title?

Example of what I want to acheive: enter image description here

Example of the output from tex: enter image description here

\documentclass[11pt, twoside, openright]{book}
\usepackage{lipsum}
\usepackage{nag}
\usepackage{lettrine}
\usepackage{fontspec}
\usepackage{leading}
\usepackage{needspace}
\usepackage{relsize}
  \renewcommand\RSpercentTolerance{0}
  \renewcommand\RSlargest{50pt}
  \renewcommand\RSsmallest{6pt}
\usepackage[singlespacing]{setspace}
\usepackage[svgnames]{xcolor}
\usepackage{changepage}
\usepackage{fancyhdr}
\usepackage[paperwidth=5.4375in, paperheight=8.375in, inner=0.4531in, outer=0.4844in, top=0.7733in, bottom=0.471in, headsep=0.1106in, footskip=0.351in]{geometry}
\setlength{\marginparwidth}{0pt}
\usepackage[none]{hyphenat}
\sloppy
\usepackage{layout}
\newenvironment{RtTitle}
  {
    \begin{center}
    \begin{spacing}{1.234}
    \fontsize{22pt}{26.4pt}\selectfont
  }
  {
    \end{spacing}
    \end{center}
  }
\widowpenalty=5000
\clubpenalty=5000
\setlength{\parskip}{3pt plus 3pt minus 0.2pt}
\setlength{\parindent}{18pt}
\setlength{\emergencystretch}{15pt} 
\setlength{\topskip}{0pt}
\frenchspacing
\leading{11.8pt}
\begin{document}
\begin{RtTitle}
\hrule
The Title
\hrule
\end{RtTitle}
\lipsum
\end{document}
2
  • I can't make any sense out of your question. Do you mind adding a picture of what you're trying to achieve?
    – naphaneal
    Jun 30, 2016 at 20:31
  • I added the example images. I hope they help explain.
    – Aaron
    Jun 30, 2016 at 21:02

1 Answer 1

5

TeX doesn't add interline glue around an \hrule. You have to add the space yourself.

Note that spacing is useless: if you want bigger leading in the title, just modify the second argument to \fontsize.

\documentclass{book}
\usepackage{lmodern} % or any other scalable font

\newenvironment{ruledtitle}
 {%
  \par % ensure being in vertical mode
  \begingroup % limit the scope for the font selection
  \fontsize{22pt}{26.4pt}\itshape\centering
  \hrule % top rule
  \vspace{3pt}% spacing
 }
 {%
  \par % end the paragraph
  \vspace{3pt} % spacing
  \hrule % bottom rule
  \endgroup
  \vspace{3\baselineskip}% space after the title
 }

\begin{document}

\begin{ruledtitle}
The Title
\end{ruledtitle}

Some text follows

\end{document}

enter image description here

However, I would use a command, for this:

\newcommand{\ruledtitle}[1]{%
  \par % ensure being in vertical mode
  \begingroup % limit the scope for the font selection
  \fontsize{22pt}{26.4pt}\itshape\centering
  \hrule % top rule
  \vspace{3pt}% spacing
  #1\par % the title
  \vspace{3pt} % spacing
  \hrule % bottom rule
  \endgroup
  \vspace{3\baselineskip}% space after the title
 }

to be called as

\ruledtitle{The Title}
2
  • Thank you. This worked great for achieving almost everything I needed. The only issue I have now is that the vspaces added in around the hrule vary from file to file. I am trying to apply these settings to over a thousand files and would like to end up with exactly the same spacing between the title and the hrules. Those spaces vary depending on the text that is on the first page of each file. Is there a way to force the spacing between the title, hrules and the start of the first paragraph to always be the same? Then the remaining vertical spacing areas can be used on the page to format with?
    – Aaron
    Jul 2, 2016 at 15:24
  • @Blujely Your description is not very clear, I'm afraid
    – egreg
    Jul 2, 2016 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .