LaTeX forum ⇒ Text FormattingLetter Header Missing First Page

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
chmst1999
Posts: 4
Joined: Sun Feb 24, 2019 7:54 am

Letter Header Missing First Page

Postby chmst1999 » Sun Feb 24, 2019 8:01 am

I am unable to figure out how to get the same header on all pages of this document. It shows up on everything but the first page, but I can't seem to get it on page 1. Can anyone help fix this problem? The following document works in my editor, but has a few errors. If there is an easier way to set this up correctly please let me know.

Here is what I want:
1. same header on all pages
2. line under header on all pages
3. be able to adjust the distance the text starts from the line below the header
  1. \documentclass[12pt]{letter} % Uses 10pt
  2. \usepackage[document]{ragged2e}
  3. \usepackage{makecell}
  4. \usepackage{graphicx}
  5. \usepackage{tabularx}
  6. \usepackage{geometry}
  7. \usepackage{fancyhdr}
  8. \pagestyle{fancy}
  9.  
  10. \geometry{
  11. letter, includehead, includefoot,
  12. total={170mm,257mm},
  13. headheight=5mm,
  14. left=20mm,
  15. }
  16. \usepackage{hyperref}
  17. \hypersetup{
  18. colorlinks=true,
  19. linkcolor=blue,
  20. filecolor=magenta,
  21. urlcolor=blue}
  22.  
  23. %Header
  24. \makeatletter
  25. \thispagestyle{plain}
  26. \def\ps@myheader{
  27. \def\@oddhead{%\includegraphics[height=20mm,left]{example-image}\hfil}
  28. \let\@evenhead\@oddhead% make right page headers the same as left
  29. \centering
  30. \begin{tabularx}{\textwidth}{ccc}
  31. &\textsc{\large\bf First A. Last}& \\
  32. &\textsc{P.O. BOX 999, Square, ZZ 11223}& \\
  33. \textsc{\Mobilefone \hspace{1mm} (555) 555-5555} & \textsc{\Letter \hspace{1mm} <!-- e --><a href="mailto:email@schools.k12.zz.us">email@schools.k12.zz.us</a><!-- e -->} & \href{http://goo.gl/AAAA}{http://goo.gl/AAAA}
  34. %\hline
  35. \end{tabularx}%
  36. }
  37. \end{centering}
  38. }
  39.  
  40. \begin{document}
  41. \let\@evenhead\@oddhead% make right page headers the same as left
  42. \pagestyle{myheader}
  43.  
  44. \signature{First And Last} % name for signature
  45. \longindentation=0pt % needed to get closing flush left
  46. \let\raggedleft\raggedright % needed to get date flush left
  47.  
  48. \begin{letter}{Mr. Whom Ever\\Superintendent\\P.O. Box 8888\\Smallville, YY 76543}
  49. \opening{Dear Mr. Ever:}
  50.  
  51. page 1
  52. \newpage
  53. page 2
  54. \newpage
  55. page 3
  56.  
  57. \vspace{\baselineskip}\linebreak
  58. \closing{Sincerely,}
  59. \encl{enclosure 1, enclosure 2} % Enclosures
  60. \end{letter}
  61. \end{document}

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Feb 24, 2019 10:11 am

Welcome to the forum.

  1. \documentclass[12pt,headsepline]{letter} % Uses 10pt
  2. \usepackage[document]{ragged2e}
  3. \usepackage{makecell}
  4. \usepackage{graphicx}
  5. \usepackage{tabularx}
  6. \usepackage{geometry}
  7.  
  8. \geometry{
  9. letterpaper,% <------- corrected
  10. includehead, includefoot,
  11. total={170mm,257mm},
  12. headheight=5mm,
  13. left=20mm,
  14. head=58.99994pt,%<------ added
  15. }
  16. \usepackage{hyperref}
  17. \hypersetup{
  18. colorlinks=true,
  19. linkcolor=blue,
  20. filecolor=magenta,
  21. urlcolor=blue}
  22.  
  23. %Header
  24. \usepackage{blindtext}
  25. \usepackage{marvosym}
  26. \usepackage{scrlayer-scrpage}
  27. \chead{
  28. \begin{tabularx}{\textwidth}{ccc}
  29. &\textsc{\large\bf First A. Last}& \\
  30. &\textsc{P.O. BOX 999, Square, ZZ 11223}& \\
  31. \textsc{\Mobilefone \hspace{1mm} (555) 555-5555} & \textsc{\Letter \hspace{1mm} <!-- e --><a href="mailto:email@schools.k12.zz.us">email@schools.k12.zz.us</a><!-- e -->} & \href{http://goo.gl/AAAA}{http://goo.gl/AAAA}
  32. %\hline
  33. \end{tabularx}%
  34. }
  35.  
  36. \begin{document}
  37.  
  38. \signature{First And Last} % name for signature
  39. \longindentation=0pt % needed to get closing flush left
  40. \let\raggedleft\raggedright % needed to get date flush left
  41.  
  42. \begin{letter}{Mr. Whom Ever\\Superintendent\\P.O. Box 8888\\Smallville, YY 76543}
  43. \opening{Dear Mr. Ever:}\thispagestyle{scrheadings}
  44.  
  45. \blindtext[22]
  46.  
  47. \vspace{\baselineskip}%\linebreak Doesn't make any sense
  48. \closing{Sincerely,}
  49. \encl{enclosure 1, enclosure 2} % Enclosures
  50. \end{letter}
  51. \end{document}



I would probably use some KOMA-stuff here.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

chmst1999
Posts: 4
Joined: Sun Feb 24, 2019 7:54 am

Postby chmst1999 » Sun Feb 24, 2019 1:01 pm

Thank you! I had some trouble compiling the email in your fix. I tried \email but I think I’ll have to define that.

Your fixes work well. However, now I have the pages numbered in the top left corner. Is there a way to remove that? I don’t see where it is being directed to number the pages.

Again, thank you!

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Feb 24, 2019 5:14 pm

I thought the letter symbols is what you want based on the code you shared.


Anyway, if you don't want the page numbers, add \ihead*{}.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

chmst1999
Posts: 4
Joined: Sun Feb 24, 2019 7:54 am

Postby chmst1999 » Sun Feb 24, 2019 6:24 pm

Johannes your work is great. This version is much better than what I had. The only thing still in there is the page numbers on the left side of the header. I don't know where to put the \ihead*{} to remove that. If I can get rid of those, this will be exactly what I need. Thanks for your help!

UPDATE: I fixed it with the line below included after the start of the document (in %%%%%)
\pagenumbering{gobble} % stops page numbering throughout document

Now the document and header work as I want without the page numbering!

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % Welcome to Overleaf --- just edit your LaTeX on the left,
  5. % and we'll compile it for you on the right. If you open the
  6. % 'Share' menu, you can invite other users to edit at the same
  7. % time. See <!-- m --><a class="postlink" href="http://www.overleaf.com/learn">http://www.overleaf.com/learn</a><!-- m --> for more info. Enjoy!
  8. %
  9. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  10.  
  11. \documentclass[12pt,headsepline]{letter} % Uses 10pt
  12. \usepackage[document]{ragged2e}
  13. \usepackage{makecell}
  14. \usepackage{graphicx}
  15. \usepackage{tabularx}
  16. \usepackage{geometry}
  17.  
  18.  
  19. \geometry{
  20. letterpaper,% <------- corrected
  21. includehead, includefoot,
  22. total={170mm,257mm},
  23. headheight=5mm,
  24. left=20mm,
  25. head=58.99994pt,%<------ added
  26. }
  27. \usepackage{hyperref}
  28. \hypersetup{
  29. colorlinks=true,
  30. linkcolor=blue,
  31. filecolor=magenta,
  32. urlcolor=blue}
  33.  
  34. %Header
  35. \usepackage{blindtext}
  36. \usepackage{marvosym}
  37. \usepackage{scrlayer-scrpage}
  38. \newcommand*{\email}[1]{\href{mailto:#1}{\nolinkurl{#1}}}
  39. \ihead*{}
  40. \chead{
  41. \begin{tabularx}{\textwidth}{ccc}
  42. &\textsc{\large\bf First A. Last}& \\
  43. &\textsc{P.O. BOX 999, Square, ZZ 11223}& \\
  44. \textsc{\Mobilefone \hspace{1mm} (555) 555-5555} & \textsc{\Letter \hspace{1mm} \email{anyone@anywhere.k12.mt.us}} & \href{http://goo.gl/AAAA}{http://goo.gl/AAAA}
  45. %\hline
  46. \end{tabularx}%
  47. }
  48.  
  49. \begin{document}
  50.  
  51. \signature{First And Last} % name for signature
  52. \longindentation=0pt % needed to get closing flush left
  53. \let\raggedleft\raggedright % needed to get date flush left
  54.  
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. \pagenumbering{gobble} % stops page numbering throughout document
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58.  
  59. \begin{letter}{Mr. Whom Ever\\Superintendent\\P.O. Box 8888\\Smallville, YY 76543}
  60. \opening{Dear Mr. Ever:}\thispagestyle{scrheadings}
  61.  
  62. \blindtext[10]
  63.  
  64. \vspace{\baselineskip}%\linebreak Doesn't make any sense
  65. \closing{Sincerely,}
  66. \encl{enclosure 1, enclosure 2} % Enclosures
  67. \end{letter}
  68. \end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 9416
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed Feb 27, 2019 11:50 am

\ohead{} instead of \ihead*{} would work here.

Stefan
Site admin


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests