Text Formattingmemoir | Move Chapter Heading to top of Page

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Xudonax
Posts: 1
Joined: Thu Dec 08, 2011 12:42 pm

memoir | Move Chapter Heading to top of Page

Post by Xudonax »

Hello all,

I have a little problem with my chapters. I found the chapterstyle below on this site. The problem is the rather high vertical space above the title. I've experimented with the -60pt and 2.5cm below, but I couldn't move it up. I also tried the titlesec package, but that didn't seem to have any effect. What do I have to do to move the chaptertitle to the top of the page?

An example of what I mean: (note: this is compiled with XeLaTeX, for LaTeX you might have to delete the fontspec and x* packages)

Code: Select all

\documentclass[11pt,a4paper,openany]{memoir}

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage[usenames,dvipsnames]{color}

\makechapterstyle{combined}{
  \setlength{\midchapskip}{-60pt}
  \setlength{\afterchapskip}{2.5cm}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapnumfont}{\normalfont\sffamily\bfseries\fontsize{80}{0}\selectfont}
  \renewcommand*{\printchapternum}{\flushright\chapnumfont\textcolor[rgb]{.64,.79,.87}{\thechapter}}
  \renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
  \renewcommand*{\printchaptertitle}[1]{%
    \raggedright\chaptitlefont\parbox[t]{\textwidth-3cm}{\raggedright##1}}
}

\chapterstyle{combined}

\begin{document}
	\chapter{This}
	Should be a bit higher
\end{document}

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

NoIdeaNickanme
Posts: 13
Joined: Wed Nov 09, 2011 5:41 pm

memoir | Move Chapter Heading to top of Page

Post by NoIdeaNickanme »

You had three errors in the code. This code now works perfectly in LaTeX:

Code: Select all

\documentclass[11pt,a4paper,openany]{memoir}

%\usepackage{fontspec}
%\usepackage{xunicode}
%\usepackage{xltxtra}
\usepackage[usenames,dvipsnames]{color}

\makechapterstyle{combined}{
  \setlength{\beforechapskip}{-2cm}     % corrected command \midchapskip to \beforechapskip
  \setlength{\afterchapskip}{2.5cm}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapnumfont}{\normalfont\sffamily\bfseries\fontsize{80}{0}\selectfont}
  \renewcommand*{\printchapternum}{\flushright\chapnumfont\textcolor[rgb]{.64,.79,.87}{\thechapter}}
  \renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
  \renewcommand*{\printchaptertitle}[1]{\vspace{-1.75cm}        % Missing \vspace inserted
    \raggedright\chaptitlefont\parbox[t]{\textwidth}{\raggedright##1}}          % deleted {\textwidth-3cm} as it is not a correct command
}

\chapterstyle{combined}

\begin{document}
   \chapter{This}
   Is now ok.
\end{document}
Post Reply