2

Question still unanswered

I am trying to set up margins equal to 2.5cm all around the document. With use of geometry (and fancyhdr) package which is:

\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}

However i have noticed that by default top and bottom margins are slightly bigger than the left and right. Why is it like that and how to fix it?

Thus how to make those margins (all of them) identical and equal to 2.5cm?

My entire code is:

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\newcommand*{\savedfootnotes}{}
\newcommand*{\resetsavedfootnotes}{\global\let\savedfootnotes\empty}
\newcommand{\tablefootnote}[1]%
{%
    \footnotemark
    \xdef\savedfootnotes%
    {\unexpanded\expandafter{\savedfootnotes}\noexpand\footnotetext{#1}}%
}
\edef\endtable%
{%
    \aftergroup\noexpand\savedfootnotes
    \aftergroup\noexpand\resetsavedfootnotes
    \unexpanded\expandafter{\endtable}%
}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage{titling}
\usepackage{array}
\usepackage{titlesec}
\usepackage{bibentry}
 \nobibliography*
\usepackage{tocloft}
 \usepackage{titling}
\newcommand{\subtitle}[1]{%
    \posttitle{%
        \par\end{center}
    \begin{center}\large#1\end{center}
    \vskip0.5em}%
}

\renewcommand\cftsecfont{\normalfont}
\renewcommand\cftsecpagefont{\normalfont}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}
\renewcommand\cftsecdotsep{\cftdot}
\renewcommand\cftsubsecdotsep{\cftdot}
\usepackage{cite}
\usepackage{fancyhdr}
\usepackage[pdftex,
pdfauthor={},
pdftitle={}]{hyperref}
%
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

 \linespread{1.5}
\fancyhf{}

\renewcommand{\headrulewidth}{0pt} 
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}

\pagestyle{fancy}
\cfoot{ \thepage}
\setlength{\droptitle}{5cm}
\setlength\parindent{1cm}

\makeatletter
\renewcommand\thesection{}
\renewcommand\thesubsection{\@arabic\c@section.\@arabic\c@subsection}
\makeatother

\titlespacing*{\section}
{2.5cm}{0 pt}{1.5 pt}
\titlespacing*{\subsection}
{2.5cm}{1.5 pt}{1.5 pt}

\setcounter{section}{-1}


\begin{document}
    \pagenumbering{gobble}


\pagenumbering{arabic}
\setcounter{page}{0}
\thispagestyle{empty}
\clearpage

title page


\newpage
\tableofcontents
\newpage
\section{\hfil 0 \hfil}
\newpage


\section{\hfil 1 \hfil}



\section{\hfil Bib \hfil}
\nocite{*}

\begingroup
\renewcommand{\section}[2]{}
\bibliographystyle{plain}
\bibliography{bibl2}

\endgroup
\newpage

\end{document}

Entire page looks like that: enter image description here

At the top of it i have 0.1 inches more that on the left hand side. I want to have 1inch everywhere


Edit by touhami

Following comments it seems that the question is how to remove the gap between the frame and section title (this is related to titlesec)

\documentclass[12pt,a4paper]{article}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm,showframe]{geometry}

\usepackage{titlesec}

\usepackage{mwe}% just for the example

\linespread{1.5}

\begin{document}
\blinddocument
\end{document}
  • 3
    Welcome to tex.SE! A minimal working example (MWE) is (nearly) always nice. Do you use headlines and footlines? Than you may have a look at the options includefoot, includehead and so on in the documentation of the geometry package. – Jürgen Mar 29 '17 at 11:42
  • 2
    I calculated identical margins of 71.13188pt on all sides. – John Kormylo Mar 29 '17 at 15:35
  • 1
    Maybe so, but is it OK without \linespread{1.5}? Which is probably not what you want, in fact. Use the facilities of setspace instead. Off-topic: hyperref should be loaded last. – cfr Mar 29 '17 at 23:31
  • 1
    You should hardly ever need \newpage in a document. Almost certainly, you are using the wrong class. – cfr Mar 29 '17 at 23:34
  • 2
    Possible duplicate of Remove spacing above section in titlesec – touhami Mar 31 '17 at 22:32
1

A solution is to not use titlesec. One can replace the stuff of this package i.e.

\usepackage{titlesec}

and

\titlespacing*{\section}
{2.5cm}{0 pt}{1.5 pt}
\titlespacing*{\subsection}
{2.5cm}{1.5 pt}{1.5 pt}

with

\makeatletter 
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-1sp \@plus -1pt \@minus -.2pt}%
                                   {1.5pt \@plus .2pt}%
                                   {\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-1.5pt \@plus -1pt \@minus -.2pt}%
                                     {1.5pt \@plus .2pt}%
                                     {\normalfont\large\bfseries}}
\makeatother

MWE

\documentclass[12pt,a4paper]{article}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm,showframe]{geometry}

\usepackage{mwe}% just for the example


\makeatletter 
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-1sp \@plus -1pt \@minus -.2pt}%
                                   {1.5pt \@plus .2pt}%
                                   {\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-1.5pt \@plus -1pt \@minus -.2pt}%
                                     {1.5pt \@plus .2pt}%
                                     {\normalfont\large\bfseries}}
\makeatother

\linespread{1.5}

\begin{document}
\section{lipsum foo}
\lipsum[1]
\section{lipsum foo}
\lipsum[1]
\subsection{lipsum foo}
\lipsum[1]
\end{document}

enter image description here

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.