Page LayoutPage numbers beside headers (LyX)

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
dschneiderch
Posts: 22
Joined: Thu Mar 31, 2011 10:41 pm

Page numbers beside headers (LyX)

Post by dschneiderch »

I've been trying to something in LyX (no section name thought, just with the page numbers.) for my thesis as described similar in another topic [1]. Which part of this solution would I need to use and where? I assume in the preamble? I appreciate your help.

[1] View topic: Page numbers "beside" headers


Thanks
Dominik
Last edited by dschneiderch on Fri Apr 22, 2011 5:30 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Page numbers beside headers (LyX)

Post by nvx »

Dominik,

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
dschneiderch
Posts: 22
Joined: Thu Mar 31, 2011 10:41 pm

Page numbers beside headers (LyX)

Post by dschneiderch »

I would like the page number "beside" the header (but only for pages that aren't the first page of a chapter). Even if I include the solution to nvx's problem, my output doesnt change. Does this mean my class file http://sites.google.com/site/nathanandr ... isusinglyx wont allow the heading/page numbers changed? There is nothing about page numbers in my preamble so I'm not quite sure what to look for otherwise.

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
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Page numbers beside headers (LyX)

Post by nvx »

Then this

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}
}
should produce what you want. "\qquad" in the code above denotes width of the gap between page numbers and text.

Just don't forget that you must put

Code: Select all

\pagestyle{fancy}
at the beginning of the document (e.g. after \begin{document}) or, generally, before the text you want to be typeset on pages with your custom page style.

nvx
dschneiderch
Posts: 22
Joined: Thu Mar 31, 2011 10:41 pm

Page numbers beside headers (LyX)

Post by dschneiderch »

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?
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}
}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Page numbers beside headers (LyX)

Post by localghost »

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? […]
This is no longer the subject of the original topic here. Please open a new thread and refer to this one.


Thorsten
dschneiderch
Posts: 22
Joined: Thu Mar 31, 2011 10:41 pm

Page numbers beside headers (LyX)

Post by dschneiderch »

localghost wrote:
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
This is no longer the subject of the original topic here. Please open a new thread and refer to this one.
I believe the first part of the question still qualifies...?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Page numbers beside headers (LyX)

Post by localghost »

dschneiderch wrote:I believe the first part of the question still qualifies...?
But not the rest. So at least for this last part you have to open a new thread.
dschneiderch
Posts: 22
Joined: Thu Mar 31, 2011 10:41 pm

Re: Page numbers beside headers (LyX)

Post by dschneiderch »

Done. See "aligning page numbers" http://www.latex-community.org/forum/vi ... 47&t=12856 for the other questions
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Page numbers beside headers (LyX)

Post by nvx »

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?
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.

Maybe someone else will be able to provide a technically correct solution.

nvx
Post Reply