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
  • Apologize, i am preparing and example just need to remove all personal informations from my document. Includefoot and infludehead are going to make this margin larger not smaller as i have checked. – Mrowkacala Mar 29 '17 at 11:56
  • It is a mess i know... It is a modification of some of my previous files thus not always consistent. – Mrowkacala Mar 29 '17 at 12:19
  • 2
    I calculated identical margins of 71.13188pt on all sides. – John Kormylo Mar 29 '17 at 15:35
  • @JohnKormylo margins are not identical as somehow header and footer are included in such a manner that they make margins at top and bottom bigger. – Mrowkacala Mar 29 '17 at 16:03
  • Not relevant, but you should have \noexpand\footnotetext{\unexpanded{#1}} instead of \noexpand\footnotetext{#1} – egreg Mar 29 '17 at 17:29
  • try with \usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm,showframe]{geometry} – touhami Mar 29 '17 at 17:33
  • @touhami ok fine, there is a gap between showframe and section title how to move section title to be adjacent to showframe? – Mrowkacala Mar 29 '17 at 17:43
  • Note, it is possible to move the PDF page origin. See http://tex.stackexchange.com/questions/183995/left-margin-wider-than-right-one – John Kormylo Mar 29 '17 at 20:15
  • 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
  • 1
    titlesec is responsible. Remove that code and there is no space. – cfr Mar 29 '17 at 23:46
  • Off-Topic: You should never need \hfil at the begin or end of \section commands. You should configure the headings instead. Note, that the \hfil will be at the table of contents and the running head too, unless you use the optional argument of \section. – Schweinebacke Mar 30 '17 at 05:39
  • The problem is related to titlesec package, do you really need to use it, (from your code it seems not necessary) – touhami Mar 30 '17 at 08:03
  • OK but when I remove titlesec package will still i have 1.5 linespread below section title and above and bellow subsection title? – Mrowkacala Mar 30 '17 at 09:53
  • yes of course, but if not just tell us what do you need exactly – touhami Mar 30 '17 at 13:00
  • I need 1.5 linespread below section title and below and above subsection title. – Mrowkacala Mar 31 '17 at 11:23
  • And after removing titlsec thus removing manually set value of linespread surrounding section titles and subsection titles i am left with linespread larger than 1.5 – Mrowkacala Mar 31 '17 at 11:27
  • what about horizontal space before (at the left of) section title because you set \titlespacing*{\section} {2.5cm}{0 pt}{1.5 pt} so section's title start at 5cm from the left edge is this what you want? – touhami Mar 31 '17 at 17:59
  • No in my original document this 2.5cm was change to 0 – Mrowkacala Mar 31 '17 at 19:02
  • probably not relevant, but \usepackage{titling} appears twice. – barbara beeton Mar 31 '17 at 20:09
  • 2
  • 1
    please see @egreg's answer here – touhami Mar 31 '17 at 22:33

1 Answers1

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

touhami
  • 19,520