1

I have formatted one page of my document in a particular way. (including alignments) Now I want to have that particular setting for every page of my document. This would have been very easy if the page was an environment. (\renewenvironment would have solved my problem) My question is is there any way to renew the definitions of a page in the preamble itself so that they'll be held throughout the document for every page.

Here is the code -

\documentclass{article}

\begin{document}
\topskip=0pt
\vspace*{\fill}
TEXT TEXT TEXT TEXT
\vspace*{\fill}
\pagebreak
\end{document}
  • \thispagestyle? \pagestyle for global setting? – user156344 Apr 23 at 14:13
  • I want every page to be vertically centered, I've a code ready with me, I just want it to be global. – Niranjan Apr 23 at 14:15
  • I think \pagestyle won't work here. There are only four valid options for that command. – Niranjan Apr 23 at 14:17
  • 2
    if you have \pagebreak now it's a single edit to make them all \end{mypage} \begin{mypage} you could do it other ways but that seems the most natural markup. – David Carlisle Apr 23 at 14:50
  • 1
    Your question is much more specific than your title implies. Consider changing it to something like "Vertically centering text on all pages of document" – erik May 23 at 20:18
1

Since you are using manual pagebreaks, you can define \mypagebreak to fill the remaining space, start a new page, and add vertical space on the next page. However, this would require you to manually provide a pagebreak every time. To automate this (in case you overflow and want the subsequent page to be vertically centered as well), you can use the atbegshi package to ensure space is added at every new page.

\documentclass{article}
\usepackage{atbegshi}
\usepackage{lipsum,graphicx}
\AtBeginDocument{\topskip=0pt\vspace*{\fill}}
\AtEndDocument{\vspace{\fill}}
\providecommand{\mypagebreak}{\par\vspace*{\fill}\clearpage}
\AtBeginShipout{\par\vspace*{\fill}}
\begin{document}
TEXT TEXT TEXT TEXT
\mypagebreak
More TEXT TEXT TEXT TEXT

\mypagebreak
\lipsum[2-7]
\end{document}
  • THIS was the solution I was looking for!! Thanks a ton. – Niranjan May 24 at 16:12
0

There are document classes that are vertically centered by default:

\documentclass{beamer}

\geometry{paper=a4paper,vmargin=0pt}
\setbeamertemplate{navigation symbols}{}

\begin{document}

\begin{frame}[allowframebreaks]

foo
\framebreak

bar
\end{frame}

\end{document}
  • beamer generally adds extra info to each page and setting beamer at the top of this master file would still require changes throughout the existing pages this question was "Given a scripted document" how to globally change all the pages to vertically centered reflow just from the initial page definition (much like a word processor could) – KJO Apr 23 at 17:41
  • Sorry, I want my document in article class. – Niranjan Apr 24 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.