Page Layout ⇒ Page numbers beside headers (LyX)
-
- Posts: 22
- Joined: Thu Mar 31, 2011 10:41 pm
Page numbers beside headers (LyX)
[1] View topic: Page numbers "beside" headers
Thanks
Dominik
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Page numbers beside headers (LyX)
It depends on which of the two aforementioned layouts you want to use (page number in the header or "beside" it). Anyway, it is enough to remember that in the definition of headers (in those \fancyhead commands) \thepage denotes page number, \leftmark chapter title and \rightmark section title (at least for "book" and "report" document classes -- I am not sure about the other ones). If you remove the titles and anything that is related to them (\qquad etc.), you should get what you want.
You might also want to flip through the fancyhdr documentation since this package is used here to define custom headers/footers.
nvx
-
- Posts: 22
- Joined: Thu Mar 31, 2011 10:41 pm
Page numbers beside headers (LyX)
I think the pagestyle being used is myheadings if that helps at all.
I'm using CU's .cls but don't go there so my advisor asked to move the page number over a bit.
Thanks for your help.
Dominik
Page numbers beside headers (LyX)
Code: Select all
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % Delete current setting for header and footer
\fancyhead[LE]{\leavevmode\llap{\thepage\qquad}}
\fancyhead[RO]{\leavevmode\rlap{\qquad\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{
\fancyhead{} % Get rid of headers and footers on plain pages...
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt} % ...and of the lines
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{empty}{
\fancyhead{} % Get rid of headers and footers on plain pages...
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt} % ...and of the lines
\renewcommand{\footrulewidth}{0pt}
}
Just don't forget that you must put
Code: Select all
\pagestyle{fancy}
nvx
-
- Posts: 22
- Joined: Thu Mar 31, 2011 10:41 pm
Page numbers beside headers (LyX)
Also, what is the appropriate way to center the bottom page number to the text instead of page (one-sided printing, left margin=1.5", right margin=1")?
I used \quad and \qquad to arrange the numbers to "look" good but would like a real solution.
Lastly, how do I move move the page numbers from the frontmatter from top right to bottom center? They are coded into the .cls so I have no where to put \thispagestyle{plain} like I did with Chapter heading pages.
That said, why is \fancyhead considered better than \fancyhfoffset in the previous example?
Thanks!
Code: Select all
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % Delete current setting for header and footer
%\fancyhead[LE]{\leavevmode\llap{\thepage\qquad\qquad}}
%\fancyhfoffset[R]{0.4in}
\fancyhead[R]{\leavevmode\rlap{\qquad\qquad\qquad\qquad\qquad\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{
\fancyhead{} % Get rid of headers and footers on plain pages...
\fancyfoot[C]{\quad\thepage}
\renewcommand{\headrulewidth}{0pt} % ...and of the lines
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{empty}{
\fancyhead{} % Get rid of headers and footers on empty pages...
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt} % ...and of the lines
\renewcommand{\footrulewidth}{0pt}
}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Page numbers beside headers (LyX)
This is no longer the subject of the original topic here. Please open a new thread and refer to this one.dschneiderch wrote:Thank you for the example! The code works basically but how do I ensure the page number is no more than 0.5 inches from any edge (so top right it should be 'square' and bottom center 0.5" up from bottom?
Also, what is the appropriate way to center the bottom page number to the text instead of page (one-sided printing, left margin=1.5", right margin=1")?
I used \quad and \qquad to arrange the numbers to "look" good but would like a real solution.
Lastly, how do I move move the page numbers from the frontmatter from top right to bottom center? They are coded into the .cls so I have no where to put \thispagestyle{plain} like I did with Chapter heading pages.
That said, why is \fancyhead considered better than \fancyhfoffset in the previous example? […]
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 22
- Joined: Thu Mar 31, 2011 10:41 pm
Page numbers beside headers (LyX)
I believe the first part of the question still qualifies...?localghost wrote:This is no longer the subject of the original topic here. Please open a new thread and refer to this one.dschneiderch wrote:Thank you for the example! The code works basically but how do I ensure the page number is no more than 0.5 inches from any edge (so top right it should be 'square'?
Thorsten
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Page numbers beside headers (LyX)
But not the rest. So at least for this last part you have to open a new thread.dschneiderch wrote:I believe the first part of the question still qualifies...?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 22
- Joined: Thu Mar 31, 2011 10:41 pm
Re: Page numbers beside headers (LyX)
Page numbers beside headers (LyX)
In case you would like page numbers to be exactly 0.5 in from the top and right edges, then I do not know. If you want the distance to be at most 0.5 in, then employ the same approach but instead of "\quad" or "\qquad" use "\hspace{...}" with the appropriate value in the curly brackets. Distance from the top and the bottom edges can be controlled by setting the layout variables -- see for instance the excellent "The not so short introduction to LaTeX". There is a chapter/section dealing with page layout.dschneiderch wrote:Thank you for the example! The code works basically but how do I ensure the page number is no more than 0.5 inches from any edge (so top right it should be 'square' and bottom center 0.5" up from bottom?
Maybe someone else will be able to provide a technically correct solution.
nvx