How do I make custom page numbering in LaTeX? [closed] - latex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I have a report with appendixes.
What I want is to use a different style on the page numbering when the appendixes start.
I use Arabic numbering until I reach the appendixes. Then I would want to do something like this:
I want the custom page numbering to be:
Chapter: A
Section: {Chapter}{1} (A-1)
\newpage
\pagenumbering{custompagenumbering}
Is this possible?

Some paragraph. Some paragraph. Some paragraph. Some paragraph. Some paragraph.
\newpage
\setcounter{page}{1}
\renewcommand{\thepage}{A-\arabic{page}}
Some paragraph. Some paragraph. Some paragraph. Some paragraph. Some paragraph.
Would this be anywhere near what you want to do? This is how you can manipulate the page counter, and the \thepage command that determines what will be printed as page number. \roman{page} would give roman numbers, \alph{page} a, b, c ...
The other sensible solution is to use the fancyhdr package, as suggested before.

First I would create one file that includes all chapters and appendixes etc. something called main.tex or thesis.tex
there you can do all the includes and document settings, and also your header and footer settings:
% Free Header and Footer
\usepackage{fancyhdr}
\lfoot[\fancyplain{}{}]{\fancyplain{}{}}
\rfoot[\fancyplain{}{}]{\fancyplain{}{}}
\cfoot[\fancyplain{}{\footnotesize\thepage}]{\fancyplain{}{\footnotesize\thepage}}
\lhead[\fancyplain{}{\footnotesize\nouppercase\leftmark}]{\fancyplain{}{}}
\chead{}
\rhead[\fancyplain{}{}]{\fancyplain{}{\footnotesize\nouppercase\sc\leftmark}}
here it would make the page number in the center of your page foot. and the chapter title on the left of your header and also on the right if your work is doubel paged.
then you can start to include your other chapters.. mine looks like that (still in thesis.tex):
% --- Start of Document ----------------------------------------
\begin{document}
\pagenumbering{roman} %roemische ziffern
\pagestyle{fancy} % Initialize Header and Footer
\include{title} % Title Page
\include{affidavit} % affidavit
\include{abstracts} % Englisch and German abstracts
\include{acknowl} % Acknowledgements
\include{glossary} % Glossary
\include{abbreviation} % Abkuerzungen
%\include{keywords} % Keywords
\include{toc} % Table of Contents
%--- Include your chapters here ----------
\setcounter{page}{1} % set page to 1 again to start arabic count
\pagenumbering{arabic}
%\include{chapter0}
\include{chapter1} % Introduction
\include{chapter2} % Background
\include{chapter3} % Konzeption
\include{chapter4} % Technische Umsetzung
\include{chapter5}
\include{chapter6}
%
%% ....
\appendix
\include{appendix} % Appendix A
\end{document}
Hope that helps! headers and footers are some time difficult, and sometime if you change \documentclass it could appear different too. ;)

If you're able to use the Memoir class (which I recommend), you can use page styles. See Chapter 7.2 Page Styles. For example, create two styles:
\pagestyle{plain} % Regular page numbering
... STUFF ...
\clearpage % make a new page numbering down here
\copypagestyle{AppendixPS}{plain}
\renewcommand{\thepage}{Chapter \chapter Section \section page \page}
\pagestyle{AppendixPS}
I haven't tested this – or used LaTeX to do this in a while – but I hope it provides some food for thought or at least puts you onto the right track.

Related

Appendix after references not in toc and figure label missing

I am trying to set up my Appendix for my master's thesis which includes basically only figures. These will be referenced at the end of the "List of figures".
My intention is to have figures called "Fig. A.1", "Fig. A.2" etc.
Also, the appendix should be part of the table of contents.
This works fine, as long as it appears before the bibliography.
However, the appendix should appear afterwards, and as soon as I move it there, the Figures are only called "Fig. .1" and it disappears from the TOC. (Note that the figures still show up in the list of figures, however with the wrong names).
How can I reach the same result while having the Appendix BELOW the references?
\documentclass[a4paper, 12pt]{article}
\usepackage{fancyhdr}
\renewcommand{\figurename}{Fig.}
\begin{document}
\tableofcontents
\fancyhead[EC]{\large REFERENCE LIST}% page header is always ``Reference List''
\fancyhead[OC]{\large REFERENCE LIST}%
\section* {Reference List} %removes the section from sections numbers and TOC
\addcontentsline {toc}{section}{Reference List} %adds the section to TOC
\bibliographystyle{THESIS2} %my custom bibliography style
\renewcommand{\section}[2]{} %removes superfluous ``References'' title
\bibliography{Literatur} %calls my .bib file
\newpage
\fancyhead[EC]{\large APPENDIX}
\fancyhead[OC]{\large APPENDIX}
\addcontentsline {toc}{section}{Appendix}
\appendix
\section{Appendix}
\end{document}
Thanks for your help!

Customize headers and footers in Latex using Sphinx

We are exploring the features of Sphinx in order to rebuild our legacy manuals. We already ported most of the former manual to Sphinx. Now I'm exploring the possibilities to adapt our company styles.
Especially, we would like to change the appearance of the headers and footers in the PDF manual. Including a company logo and changing the appearance of even and odd pages.
Hence, I included the following preamble in my conf.py with a custom pagestyle using the package fancyhdr.
latex_elements = {
'preamble' : '''\
\\pagestyle{fancy}
\\fancyhf{}
\\fancyhead[LE,RO]{My Header}'''
}
Unfortunately, the headers only changes before begin{document}, afterwards the Sphinx Style File sphinx.sty overwrites somehow my settings.
The following snippet from sphinx.sty might cause the issue:
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
\spx#ifundefined{fancyhf}{}{
% Use \pagestyle{normal} as the primary pagestyle for text.
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\fancyfoot[LO]{{\py#HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py#HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py#HeaderFamily \#title, \py#release}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% define chaptermark with \#chappos when \#chappos is available for Japanese
\spx#ifundefined{#chappos}{}
{\def\chaptermark##1{\markboth{\#chapapp\space\thechapter\space\#chappos\space ##1}{}}}
}
% Update the plain style so we get the page number & footer line,
% but not a chapter or section title. This is to keep the first
% page of a chapter and the blank page between chapters `clean.'
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
}
}
What might be a possible workaround?
The table of contents code (in sphinxmanual.cls) ends up with
\ifdefined\fancyhf\pagestyle{normal}\fi
The comment in sphinx.sty says:
% Use \pagestyle{normal} as the primary pagestyle for text.
Thus the simplest should be for your conf.py setting to overwrite the \fancypagestyle{normal}, just re-issue it to your liking.
You will need to wrap the whole latex in \makeatletter...\makeatother if you use \py#HeaderFamily. And use Python raw strings to avoid having to double all backslashes.
in details, here I copy the original definition to conf.py so that it can be customized from there
latex_elements = {
'preamble': """
\makeatletter
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\fancyfoot[LO]{{\py#HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py#HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py#HeaderFamily \#title, \py#release}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% define chaptermark with \#chappos when \#chappos is available for Japanese
\spx#ifundefined{#chappos}{}
{\def\chaptermark##1{\markboth{\#chapapp\space\thechapter\space\#chappos\space ##1}{}}}
}
\makeatother
""",
}

LaTeX - Lots of sections (with no content) running of the edge of the page?

I have a LaTeX document like this:
\documentclass{article}
\begin{document}
\section{1}
\section{2}
\section{3}
\section{4}
\section{5}
\section{6}
\section{7}
\section{8}
\section{9}
\section{10}
\section{11}
\section{12}
\section{13}
\section{14}
\section{15}
\section{16}
\section{17}
\section{18}
\section{19}
\section{20}
\section{21}
\section{22}
\section{23}
\section{24}
\section{25}
\section{26}
\section{27}
\section{28}
\section{29}
\section{30}
\end{document}
Lots of section headings, but no text in
It produces something like this:
As you can see it keeps all the section headings on one page, and won't break it into 2 pages. Everything above 26 has disappeared off the end of the page.
Is there anyway to get LaTeX to split these sections across multiple pages? I can't easily change the actual content of body, since it's autogenerated. I can change the preamble though. Is there anyway to do this by changing the preamble?
Adding \mbox{} after a section heading would allow the page break. You could introduce it globally in the preamble by:
\makeatletter
\g#addto#macro\#afterheading{\mbox{}}
\makeatother
or
\makeatletter
\expandafter\def\expandafter\#afterheading\expandafter{\#afterheading\mbox{}}
\makeatother
like in this expandafter example.
You should be able to do something like this with the sectsty package

How to make cheat sheets in Latex? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I want to make cheat sheets for my personal use. I want to use this opportunity to get a good hand on LaTeX too. (I am already comfortable making simple documents math related in LaTeX.)
Now I want to try making cheat sheets in LaTeX. But I don't know how to do it. In cheat sheets, usually the page is split into multiple rectangular sections and each one has a few commands or notes inside it. Each rectangular section has a border etc.
How can it be done in LaTeX? Are any packages available to do this? Do you think TikZ will be a good idea for this?
Because some professors allowed us to use cheat sheets written on a computer for exams, I decided to create a template some time ago to save enough space as possible but keep readibility. The template uses the code of the answer here.
Update: The complete source code can now be found here.
The base file looks like this:
\documentclass[10pt,landscape,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,arrows,fit,calc,graphs,graphs.standard}
\usepackage[nosf]{kpfonts}
\usepackage[t1]{sourcesanspro}
%\usepackage[lf]{MyriadPro}
%\usepackage[lf,minionint]{MinionPro}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage[top=0mm,bottom=1mm,left=0mm,right=1mm]{geometry}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{microtype}
\let\bar\overline
\definecolor{myblue}{cmyk}{1,.72,0,.38}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(0:2cm) circle (1.5cm)}
\colorlet{circle edge}{myblue}
\colorlet{circle area}{myblue!5}
\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
outline/.style={draw=circle edge, thick}}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\everymath\expandafter{\the\everymath \color{myblue}}
\everydisplay\expandafter{\the\everydisplay \color{myblue}}
\renewcommand{\baselinestretch}{.8}
\pagestyle{empty}
\global\mdfdefinestyle{header}{%
linecolor=gray,linewidth=1pt,%
leftmargin=0mm,rightmargin=0mm,skipbelow=0mm,skipabove=0mm,
}
\newcommand{\header}{
\begin{mdframed}[style=header]
\footnotesize
\sffamily
Cheat sheet\\
by~Your~Name,~page~\thepage~of~2
\end{mdframed}
}
\makeatletter
\renewcommand{\section}{\#startsection{section}{1}{0mm}%
{.2ex}%
{.2ex}%x
{\color{myblue}\sffamily\small\bfseries}}
\renewcommand{\subsection}{\#startsection{subsection}{1}{0mm}%
{.2ex}%
{.2ex}%x
{\sffamily\bfseries}}
\def\multi#column#out{%
\ifnum\outputpenalty <-\#M
\speci#ls \else
\ifvoid\colbreak#box\else
\mult#info\#ne{Re-adding forced
break(s) for splitting}%
\setbox\#cclv\vbox{%
\unvbox\colbreak#box
\penalty-\#Mv\unvbox\#cclv}%
\fi
\splittopskip\topskip
\splitmaxdepth\maxdepth
\dimen#\#colroom
\divide\skip\footins\col#number
\ifvoid\footins \else
\leave#mult#footins
\fi
\let\ifshr#kingsaved\ifshr#king
\ifvbox \#kludgeins
\advance \dimen# -\ht\#kludgeins
\ifdim \wd\#kludgeins>\z#
\shr#nkingtrue
\fi
\fi
\process#cols\mult#gfirstbox{%
%%%%% START CHANGE
\ifnum\count#=\numexpr\mult#rightbox+2\relax
\setbox\count#\vsplit\#cclv to \dimexpr \dimen#-1cm\relax
\setbox\count#\vbox to \dimen#{\vbox to 1cm{\header}\unvbox\count#\vss}%
\else
\setbox\count#\vsplit\#cclv to \dimen#
\fi
%%%%% END CHANGE
\set#keptmarks
\setbox\count#
\vbox to\dimen#
{\unvbox\count#
\remove#discardable#items
\ifshr#nking\vfill\fi}%
}%
\setbox\mult#rightbox
\vsplit\#cclv to\dimen#
\set#keptmarks
\setbox\mult#rightbox\vbox to\dimen#
{\unvbox\mult#rightbox
\remove#discardable#items
\ifshr#nking\vfill\fi}%
\let\ifshr#king\ifshr#kingsaved
\ifvoid\#cclv \else
\unvbox\#cclv
\ifnum\outputpenalty=\#M
\else
\penalty\outputpenalty
\fi
\ifvoid\footins\else
\PackageWarning{multicol}%
{I moved some lines to
the next page.\MessageBreak
Footnotes on page
\thepage\space might be wrong}%
\fi
\ifnum \c#tracingmulticols>\thr##
\hrule\allowbreak \fi
\fi
\ifx\#empty\kept#firstmark
\let\firstmark\kept#topmark
\let\botmark\kept#topmark
\else
\let\firstmark\kept#firstmark
\let\botmark\kept#botmark
\fi
\let\topmark\kept#topmark
\mult#info\tw#
{Use kept top mark:\MessageBreak
\meaning\kept#topmark
\MessageBreak
Use kept first mark:\MessageBreak
\meaning\kept#firstmark
\MessageBreak
Use kept bot mark:\MessageBreak
\meaning\kept#botmark
\MessageBreak
Produce first mark:\MessageBreak
\meaning\firstmark
\MessageBreak
Produce bot mark:\MessageBreak
\meaning\botmark
\#gobbletwo}%
\setbox\#cclv\vbox{\unvbox\partial#page
\page#sofar}%
\#makecol\#outputpage
\global\let\kept#topmark\botmark
\global\let\kept#firstmark\#empty
\global\let\kept#botmark\#empty
\mult#info\tw#
{(Re)Init top mark:\MessageBreak
\meaning\kept#topmark
\#gobbletwo}%
\global\#colroom\#colht
\global \#mparbottom \z#
\process#deferreds
\#whilesw\if#fcolmade\fi{\#outputpage
\global\#colroom\#colht
\process#deferreds}%
\mult#info\#ne
{Colroom:\MessageBreak
\the\#colht\space
after float space removed
= \the\#colroom \#gobble}%
\set#mult#vsize \global
\fi}
\makeatother
\setlength{\parindent}{0pt}
\begin{document}
\small
\begin{multicols*}{5}
\input{section1}
\end{multicols*}
\end{document}
When you use the code copy the template and put your LaTeX code in external files like section1.tex, section2.tex,.... Than you can easily follow the normal structure inside these LaTeX files like
\section{Title of section 1}
\subsection*{Title of subsection 1}
Some text...
\subsection*{Title of subsection 2}
With some colored math $\sum_{i=1}^\infty i$.
Inserting an image also works:\\
\includegraphics[width=\linewidth]{yourimage.png}
After filling your sections you'll get a much compressed document which still looks good like this:
I've been making my own cheat sheets as well for various things. I really like how the Latex cheat sheet found here looks. I suggest grabbing the tex source and stealing some ideas from it :).
Consider using multicol.
And consider familiarizing yourself with CTAN. Most things TeX end up there sooner or later, though it does require some digging if you don't know what you're looking for.
Here is a beautiful example of a cheat sheet (is a booklet actually, not just a couple of pages).
http://clqr.boundp.org/index.html
It is made using LaTex. It summarizes all the symbols on the Common Lisp Standard. Maybe you can pick up one or two tips from the available LaTeX source.
I like how these cheat sheets look like:
http://michaelgoerz.net/refcards/

How to avoid a page break before start of bibliography? [duplicate]

This question already has answers here:
How to have no pagebreak after \include in LaTeX
(5 answers)
Closed 8 years ago.
I am in the progress of writing an expose for my master thesis. One point in the expose is an overview of literature. To save my time and work I use bibtex to create that chapter. The thing I want to change now is that latex starts a new page for the bibliography which is an enormous overhead in a four page document.
The, I think, relevant parts from my document are:
\documentclass [ fontsize = 12pt,
paper = a4,
paper = portrait,
twoside = false,
headsepline,
twocolumn = false,
numbers=noenddot
]{scrartcl}
\bibliographystyle{unsrt}
\begin{document}
%
\include{text}
\nocite{*}
\singlespacing
\bibliography{literature}
%
\end{document}
I am using biblatex. This solved the problem:
\begingroup
\let\clearpage\relax
\printbibliography
\endgroup

Resources