-1

The height from the top of the page is currently 3.5cm to top of chapter. I want to reduce to 1.5cm. Height from bottom of chapter is currently 1.5cm and I want to reduce to 0.5cm if possible. I have tried to resolve Questions 407843 and 28195992 and 148747 without success. I've put the code in the preamble and I'm not sure if that was correct?


I have an example but etoolbox example is not correct and I do not know why. My book has 14 chapters and I have used in this example some of the info in the preamble of it. Btw, the bibliography that was an issue was solved, thanks to those who worked on it.

\documentclass[pdftex,11pt,a4paper]{book} % report maybe book??
\usepackage{titlesec}

\usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{amsthm} \usepackage{afterpage} \usepackage{color} \usepackage{fancyhdr} \usepackage{float} \usepackage{typearea} \usepackage{titlesec} \usepackage{graphicx} \usepackage[all]{xy} \usepackage{pdfpages} \usepackage{multicol} \usepackage{url} \usepackage{textcomp} \usepackage{lmodern}% http://ctan.org/pkg/lm

\usepackage{hyperref} % Needs to be last package included
\usepackage[alphabetic,initials,nobysame]{amsrefs} %must be loaded after hyperref to work properly

%\texorpdfstring{tex}{string}

\hypersetup{ unicode=false, % non-Latin characters in Acrobat’s bookmarks pdftoolbar=true, % show Acrobat’s toolbar? pdfmenubar=true, % show Acrobat’s menu? pdffitwindow=false, % window fit to page when opened pdfstartview={FitH}, % fits the width of the page to the window pdftitle={Thermal Fluid Heating, A Practical Guide for the Thermal Fluid Practitioner}, % title pdfauthor={Geoff Senior}, % author pdfsubject={Thermal Fluid Heating}, % subject of the document pdfcreator={Geoff Senior}, % creator of the document pdfproducer={Geoff Senior}, % producer of the document pdfkeywords={Thermal Fluid Heating, Hot Oil Heating, High Temperature Oil Heating}, % list of keywords pdfnewwindow=true, % links in new window colorlinks=true, % false: boxed links; true: colored links linkcolor=black, %red, % color of internal links % black for print, red for electronic citecolor=black, %green, % color of links to bibliography % black for print, green for electronic filecolor=black, %magenta, % color of file links % black for print, magenta for electronic urlcolor=black %cyan % color of external links % black for print, cyan for electronic }

% Set margins

\usepackage[inner=20mm, outer=10mm, textwidth=150mm, paperwidth=210mm, paperheight=297mm]{geometry} \setlength{\voffset}{-1.45in} \setlength{\textwidth}{18cm} \setlength{\textheight}{27cm} \setlength{\topmargin}{1.5cm} \setlength{\headsep}{15pt} % Optional - separation between header and top of text - default is 25pt \setlength{\footskip}{-0.25in} % Optional - separation between footer and bottom of text - default is 30pt

% Fancyhdr commands \setlength{\headheight}{15pt} \pagestyle{fancy} \fancyhf{}

\makeatletter \renewcommand{\chaptermark}[1]{\markboth{@chapapp\ \thechapter:\ #1}{}} \makeatother \renewcommand{\sectionmark}[1]{\markright{\thesection:\ #1}{}} \fancyhead[LE]{\slshape \leftmark} \fancyhead[RO]{\slshape \rightmark} \fancyfoot[C]{\thepage}

\setlength{\parindent}{0pt}

% setting level of subsections \setcounter{secnumdepth}{4}

\pdfminorversion=7

\usepackage{etoolbox} %etoolbox \makeatletter \patchcmd{@makeschapterhead}{50\p@}{\chapheadtopskip}{}{} \patchcmd{@makeschapterhead}{40\p@}{\chapheadbelowskip}{}{} \makeatother % Set new lengths \newlength{\chapheadtopskip}\setlength{\chapheadtopskip}{20pt} \newlength{\chapheadsep}\setlength{\chapheadsep}{40pt} \newlength{\chapheadbelowskip}\setlength{\chapheadbelowskip}{15pt}

\newcommand{\blanknonumber}{\newpage \thispagestyle{empty}}

\makeatletter \renewcommand{\chaptermark}[1]{\markboth{@chapapp\ \thechapter:\ #1}{}} \makeatother \renewcommand{\sectionmark}[1]{\markright{\thesection:\ #1}{}}

\titleformat{\chapter}[display] {\bfseries\Huge} {\LARGE\filright\MakeUppercase{\chaptertitlename} \Huge\thechapter} {2ex} {\titlerule \vspace{1ex}% \filright} [\vspace{1ex}% \titlerule]

%\frontmatter %Set pages to roman (i, ii, ...)

\makeatletter @openrighttrue \makeatother

\begin{document}

\texorpdfstring{tex}{string} \addcontentsline{toc}{chapter}{Table of Contents} \tableofcontents \addcontentsline{toc}{chapter}{List of Figures} \listoffigures \newgeometry{textwidth=150mm}

\restoregeometry

\chapter{Introduction} \label{chapter_introduction} \fancyhead[LE]{\slshape \leftmark} \fancyhead[RO]{\slshape \rightmark} \fancyfoot[C]{\thepage} \flushbottom The motive behind writing this book is to provide, as a guide, some practical information about thermal fluid heating systems as used in industrial heating applications. \

\chapter{Thermal Fluid Systems} \label{chapter_Thermal Fluid Systems} \noindent \section{Historical} \label{history} There is not much that can be found regarding the history of hot oil heating, however it is believed that its inception was as a result of Oil Companies or Road Paving Organisations (circa 1940's) wanting to heat bitumen without the use of steam, particularly so in a road making environment, away from the refinery locations where high pressure equipment was paramount.

\end{document}

Werner
  • 603,163
  • 1
    Can you please show, what you've exactly done? Best would be, to show a minimal working example starting with \documentclass and ending with \end{document}. Otherwise we cannot know why the (working) code of the answers to those question do not work in your case. Maybe you are using an incompatible class. Maybe you are using incompatible packages. Maybe there was a mistake with your integration of the code. – cabohah May 02 '23 at 06:41
  • Note also: There is no question 28195992. Because of this I wasn't able to add a link to that one. But I've added a links to the two other questions. However, 14747 seems to be completely unrelated to your problem. But I've tested the answers of 407843 and they work (but in the second I would replace the 1cm by 0cm). – cabohah May 02 '23 at 06:47
  • Does "top of page" include the margin above the text area? The distance from the top of the text area to the top of page is normally handled by the geometry package. \chapter adds another 50pt or so. – John Kormylo May 02 '23 at 11:35
  • I am unable to understand the response to the question. When it runs, the top of page gap is the same as original, similarly the distance from the text to the bottom of the header is also the same. It seems the etoolbox code is not changing anything. Am I missing something? – Geoff Senior May 03 '23 at 05:06
  • If you load titlesec you should not patch \@makeschapterhead etc. but use the interface of titlesec. – cabohah May 06 '23 at 08:24
  • 1
    Off-Topic: Not only for a MWE but generally, you should not load packages several times, because this makes it hard to manage a document. – cabohah May 06 '23 at 08:25
  • 1
    Off-Topic: Loading package url without options before loading hyperref usually does not make sense. – cabohah May 06 '23 at 08:26
  • 1
    Off-Topic: Manually changing of page layout lengths after loading package geometry is not recommended. You should use the geometry user interface instead. – cabohah May 06 '23 at 08:28
  • 1
  • 1
    Off-Topic: Using \@openrighttrue in the document preamble is not recommended. If available, you should always use the official user interface, e.g., class option openright. But because the default of book is already twoside,openright, it is also not needed. – cabohah May 06 '23 at 08:32
  • 1
    Off-Topic Conclusion: You should first, remove all not needed, not used, senseless and maybe spurious code from your preamble. Sometimes this already fixes several issues, sometimes it is only for a better handling of the document. – cabohah May 06 '23 at 08:36
  • 1
    You have typearea and geometry that fight each other doing similar things, but you manually set the page dimensions. It's a clear sign that you received a preamble developed by accretion without actually knowing what each part does. For instance, \voffset and \hoffset should never be set unless this is needed to cope with some printing machine's idiosyncrasies. – egreg May 06 '23 at 09:58

1 Answers1

0

To long for a comment …

Your mistake here is, to try to use both: Patching \@makeschapterhead and the titlesec interface to change the chapter headings. Using titlesec result in a changed definition of \@makeschapterhead, so the patch is no longer successful. You can test this, by adding an patch failure handling to your \patchcmd commands, e.g.

\makeatletter
\patchcmd{\@makeschapterhead}{50\p@}{\chapheadtopskip}{}{\errmessage{Cannot
    patch \string\@makeschapterhead\space above skip value}}
\patchcmd{\@makeschapterhead}{40\p@}{\chapheadbelowskip}{}{\errmessage{Cannot
    patch \string\@makeschapterhead\space below skip value}}
\makeatother

would result in

Cannot patch \@makeschapterhead above skip value.
<argument> ...chapterhead \space above skip value}

l.83 ...@makeschapterhead\space above skip value}}

Cannot patch @makeschapterhead below skip value. <argument> ...chapterhead \space below skip value}

l.85 ...@makeschapterhead\space below skip value}}

So have to either remove the titlesec package and the titlesec code and use the patch from Mico's answer to the already linked question. In this case please also note, that \@makeschapterhead is the command used by \chapter* (with star) only. For \chapter (without star) you also need to patch \@makechapterhead as shown in the already linked answer. Alternatively you can remove the patch and use the titlesec interface as shown in chadoulis' answer to the already linked question.

Note that there are several other things about your code that I consider questionable. I have written some comments about this. For this reason I will not post the complete code again. A minimized complete example using titlesec would be:

\documentclass[12pt,a4paper]{book}

\usepackage{titlesec} \titleformat{\chapter}[display]{\normalfont\Huge\bfseries}{\chaptertitlename
\thechapter}{0.25cm}{\Huge}% see titlesec manual \titlespacing{\chapter}{0pt}{1.5cm}{0.5cm}% see titlesec manual

\usepackage{lipsum}% for demonstration only.

\begin{document}

\chapter{Title of Chapter} \lipsum

\end{document}

You can reduce the 1.5cm even to a negative value, if your 1.5cm are from the top of the page instead of from the start of the text area.

A minimized complete example not using titlesec but patching the class would be:

\documentclass[12pt,a4paper]{book}

\usepackage{etoolbox} % for "\patchcmd" macro \makeatletter % Reduce extra space between start of text area and and chapter header lines: \patchcmd{@makechapterhead} {50\p@}{1.5cm }{}{\errmessage{Cannot patch \string@makechapterhead\space above skip value}}% for \chapter \patchcmd{@makeschapterhead}{50\p@}{1.5cm }{}{\errmessage{Cannot patch \string@makeschapterhead\space above skip value}} % for \chapter* % Reduce extra space between chapter header and section header lines by 50%: \patchcmd{@makechapterhead} {40\p@}{0.5cm }{}{\errmessage{Cannot patch \string@makechapterhead\space below skip value}}% for \chapter \patchcmd{@makeschapterhead}{40\p@}{0.5cm }{}{\errmessage{Cannot patch \string@makeschapterhead\space below skip value}} % for \chapter* % Optionally reduce the extra space between number line and title text \patchcmd{@makechapterhead} {20\p@}{0.25cm }{}{\errmessage{Cannot patch \string@makechapterhead\space number title skip value}}% for \chapter only \makeatother

\usepackage{lipsum}% for demonstration only.

\begin{document} \chapter{Background} \lipsum \end{document}

Once again, the cm values could even be negative, if you would like.

cabohah
  • 11,455
  • The example you wrote worked fine with – Geoff Senior May 06 '23 at 23:32
  • The use of \use{package{titlesec} example was successful. package etoolbox was deleted. %using \usepackage{titlesec} \titleformat{\chapter}[display]{\normalfont\Huge\bfseries}{\chaptertitlename
    \thechapter}{0.25cm}{\Huge}% see titlesec manual \titlespacing{\chapter}{0pt}{-1.5cm}{0.5cm}% see titlesec manual was the successful code. The -1.5cm worked perfectly. Thanks for your patience. Thanks also to @werner for your assistance.
    – Geoff Senior May 07 '23 at 01:32