1

I am trying to create a document in latex but I am having difficulties with the chapter location.

On each page of my document I want one chapter, but I want to have it in the top left of the page. However, in my attempt there seems to be a big white gap.

Below is a screenshot of what I am seeing enter image description here enter image description here

Here is my code:

\documentclass
[oneside,landscape,tikz,border=2pt,png]
{book}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage{tikz}
\usepackage{smartdiagram}

\usepackage[absolute,overlay]{textpos} \setlength{\TPHorizModule}{1mm} \setlength{\TPVertModule}{1mm} \usetikzlibrary{shapes.symbols}

\tikzset{sequence item/.append style={ /utils/exec={\ifnum\xi=1 \tikzset{signal from=nowhere} \fi } } }

\usepackage[left=0.2in,right=0.2in,bottom=0.5in]{geometry}

\usepackage[ automark, autooneside=false, markcase=noupper, headsepline, headwidth=\the\textwidth+12mm:-5mm, ]{scrlayer-scrpage} \clearpairofpagestyles \rehead{\leftmark} \lohead{\rightmark} \ohead{\pagemark} \renewcommand\chaptermarkformat{}% no chapternumber in header \setkomafont{pageheadfoot}{\normalfont} \renewcommand*{\pagemark}{{\usekomafont{pagenumber}{\thepage}}}

% define new layers \DeclareNewLayer[ background, oddpage, align=tr, hoffset=\paperwidth, voffset=0pt,%distance from top width=1cm,% width of the swatch height=\dimexpr\voffset+1in+\topmargin+\headheight\relax,% height of the swatch contents={\textcolor{swatchcolor}{\rule{\layerwidth}{\layerheight}}} ]{swatch.odd} \DeclareNewLayer[ clone=swatch.odd, evenpage, align=l, hoffset=0pt ]{swatch.even}

\DeclareNewLayer[ foreground, oddpage, align=br, hoffset=\paperwidth, voffset=\paperheight, width=3em, height=2\baselineskip, contents={{% \setlength{\fboxsep}{0pt}% \colorbox{white}{\parbox[c][\layerheight][c]{\layerwidth}{\centering\pagemark}}% }} ]{pagenumberouterbottom.odd} \DeclareNewLayer[ clone=pagenumberouterbottom.odd, evenpage, align=bl, hoffset=0pt ]{pagenumberouterbottom.even} \addtokomafont{pagenumber}{\color{black}\bfseries} \AddLayersToPageStyle{scrheadings}{pagenumberouterbottom.odd,pagenumberouterbottom.even} \AddLayersToPageStyle{plain}{pagenumberouterbottom.odd,pagenumberouterbottom.even}

% add layers to every pagestyle \AddLayersToPageStyle{@everystyle@}{swatch.odd,swatch.even}

\newcommand\swatchcolor[1]{\colorlet{swatchcolor}{#1}} \swatchcolor{white}

%Font

\usepackage{carlito} \usepackage{fontspec} \setmainfont{Carlito}

\begin{document} \tableofcontents \newpage \vspace{-2in} \chapter*{First chapter}\swatchcolor{red}

\Blindtext[1]

\newpage
\chapter{Second chapter}\swatchcolor{blue}

\Blindtext[1]

\chapter{Third chapter}\swatchcolor{green}

\Blindtext[1]

\end{document}

2 Answers2

2

By messing around with the top option provided by the geometry package I've come up with this: hard fix which is a fix, but it is not really pleasing and it changes the page format globally (as you can see the red rectangle in the top right corner is now gone).

Another way of removing the whitespace is through the titlesec package.

I personally do not see any issues with the title being in the centre of the page (I also think it's an intended feature). If you're trying to achieve a presentation style it would be better to use the beamer class.

Why not use the standard portrait page format?

Code

\usepackage{geometry}
\geometry{
    top = -2cm,
    left=0.2in,
    right=0.2in,
    bottom=0.5in
}
\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{-150pt}{40pt}
sRavioli
  • 136
  • 1
    Hi, hadn't really considered the beamer class before. However, I am using a smart diagram and it doesn't seem to work in the beamer class. Therefore I'm trying to force it the other way. Ideally my headings will be in a similar position as a frame header is on the beamer class – Seddon016 Mar 16 '21 at 22:35
  • Hi, did the titlesec package help by any means? – sRavioli Mar 16 '21 at 22:39
  • 1
    Unfortunately it didn't seem to change the position (without the top -2). But like you mentioned it deletes the marks in the top right of the page. I've added a new screenshot with the showframe option. Is there anyway to move the header to there? – Seddon016 Mar 16 '21 at 22:43
  • the fancyhdr package offers this kind of options; here is the manual – sRavioli Mar 17 '21 at 08:30
0

The titlesec package came to mind, it include \titlespacing*{\chapter}{left space}{vertical space before title}{vertical space after title} which allows you to adjust the position of chapter.

In order to do this you have to also change titleformat of chapter. From their guide (titlesec.pdf https://www.ctan.org/pkg/titlesec):

\titlespacing does not work with either \chapter and \part unless you change its title format as well by means of \titleformat, the simple settings, or \titleclass.

It has to be combined with edit in geometry of the page.

\setlength{\textwidth}{width page}
\setlength{\textheight}{height page}