I am trying to get both the text aligned with the header, and even verical spacing before and after equations.
My first version of the code returns aligned text, but uneven equation spacing:
\documentclass[12pt,openright,twoside]{book}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{pdflscape}
\usepackage{newtxtext}
\usepackage[varvw]{newtxmath}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage[nottoc]{tocbibind}
\usepackage{titleps}
\titleformat{\chapter}[display]
{\bfseries\Huge}
{}
{-7ex}
{\titlerule
\vspace{2ex}%
\filright
\ifnum\value{chapter} > 0
\Huge\arabic{chapter}.
\else
\fi
}
[\vspace{2ex}%
\titlerule]
\newpagestyle{main}{%
\setheadrule{10pt}%
\headrule
\sethead[\textit{\thesection.\hspace{4pt}\sectiontitle}][][\thepage]%headers on even page (left-centre-right)%
{\thepage}{}{\textit{\thechapter.\hspace{4pt}\chaptertitle}}% headers on odd pages
%\setfoot{}{\thepage}{}
}
\pagestyle{main}
\geometry{
a4paper,
total={210mm,297mm},
left=25.0mm,
right=25.0mm,
top=25.0mm,
bottom=30.0mm,
}
\begin{document}
\chapter{This is a chapter}
\newpage
This is aligned text. This is aligned text. This is aligned text. This is aligned text. This is aligned text. This is aligned text.
Here is an example of an equation:
\begin{align}
n_i=n; && n_e=n e^{e\phi(\mathbf{x})/k_BT},
\label{1.2}
\end{align}
\noindent
This is uneven spacing.
\end{document}
This returns uneven spacing for equations:
I tried some solutions for the spacing, such as the one in this question:
\documentclass[12pt,openright,twoside]{book}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{pdflscape}
\usepackage{newtxtext}
\usepackage[varvw]{newtxmath}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage[nottoc]{tocbibind}
\usepackage{titleps}
\titleformat{\chapter}[display]
{\bfseries\Huge}
{}
{-7ex}
{\titlerule
\vspace{2ex}%
\filright
\ifnum\value{chapter} > 0
\Huge\arabic{chapter}.
\else
\fi
}
[\vspace{2ex}%
\titlerule]
\newpagestyle{main}{%
\setheadrule{10pt}%
\headrule
\sethead[\textit{\thesection.\hspace{4pt}\sectiontitle}][][\thepage]%headers on even page (left-centre-right)%
{\thepage}{}{\textit{\thechapter.\hspace{4pt}\chaptertitle}}% headers on odd pages
%\setfoot{}{\thepage}{}
}
\pagestyle{main}
\geometry{
a4paper,
total={210mm,297mm},
left=25.0mm,
right=25.0mm,
top=25.0mm,
bottom=30.0mm,
}
\expandafter\def\expandafter\normalsize\expandafter{%
\normalsize
\setlength\abovedisplayskip{3pt}
\setlength\belowdisplayskip{18pt}
\setlength\abovedisplayshortskip{2pt}
\setlength\belowdisplayshortskip{18pt}
}
\begin{document}
\chapter{This is a chapter}
\newpage
This is unaligned text. This is unaligned text. This is unaligned text. This is unaligned text. This is unaligned text. This is unaligned text.
Here is an example of an equation:
\begin{align}
n_i=n; && n_e=n e^{e\phi(\mathbf{x})/k_BT},
\label{1.2}
\end{align}
\noindent
This is even spacing.
\end{document}
But this results in unaligned text:
Am I doing something wrong in the code? Is there a solution or a workaround for this?
Thank you!