1

I am coding a monograph template with 1-inch margins on the left and right of each page. The page header contains the title of the monograph. The header on lefthand, even-numbered pages (LE) and the header on righthand, odd-numbered pages (RO) are to be balanced: the text of the LE header is to start 0.5 inches in from the left margin, and the text of the RO header is to end 0.5 inches in from the right margin. In the MWE below, the LE header is correct but the RO is not—the text ends at the right margin, not 0.5 inches in from it. The title of an actual monograph using this template may be longer or shorter than the placeholder title, so the template doesn't know where the text in an RO header will begin. How does one code for a text string of indeterminate length to end at a specific point on the line? Compiled with XeLaTeX.

\documentclass[12pt, openany]{book}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{fancyhdr}
   \pagestyle{fancy}
\fancypagestyle{monographstyle}{
  \fancyhf{} 
  \fancyhead[RO]{
    \begin{minipage}{\textwidth}
      \raggedleft
      \hspace*{-0.5in}
      {\fontsize{8pt}{10pt}\selectfont\sffamily\bfseries\
      The Placeholder Title of the Monograph}
    \end{minipage} }
  \fancyhead[LE]{
    \begin{minipage}{\textwidth}
      \raggedright
      \hspace*{0.5in}
      {\fontsize{8pt}{10pt}\selectfont\sffamily\bfseries\
      The Placeholder Title of the Monograph}
    \end{minipage} } }
\begin{document}
\pagestyle{monographstyle}
Lorem ipsum....
\newpage
Lorem ipsum....
\end{document}
3
  • 1
    Did you try adding \hspace*{0.5in} at the end of the line for the RO header? Commented Oct 7 at 17:51
  • Thank you, yes that works! Commented Oct 7 at 18:29
  • Welcome to TeX.SX! Commented Oct 7 at 19:22

1 Answer 1

2

Simply by putting a bit of space after it via either \hspace*{.5in} or a \kern.5in. Please note that you shouldn't need the minipages. The following should result in what you intended.

Please note however, that you're getting warnings because the headheight is smaller than what you put in your head. If you remove the groups around your font assignments the spacing will be what you defined in your manual \fontsize call and you'll not get those warnings (the following does that).

\documentclass[12pt, openany]{book}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{fancyhdr}

\fancypagestyle{monographstyle}
  {%
    \fancyhf{}%
    \fancyhead[RO]
      {%
        % {%
          \fontsize{8pt}{10pt}\selectfont\sffamily\bfseries
          The Placeholder Title of the Monograph
        % }%
        \kern.5in
      }%
    \fancyhead[LE]
      {%
        \leavevmode\kern.5in
        % {%
          \fontsize{8pt}{10pt}\selectfont\sffamily\bfseries
          The Placeholder Title of the Monograph%
        % }%
      }%
  }
\pagestyle{monographstyle}

\begin{document}
Lorem ipsum....
\newpage
Lorem ipsum....
\end{document}

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.