1

I am writing a text using \paragraph, and I am completely baffled as to why the 1st paragraph has no space between it and the above text whereas the 2nd does! If I add one more paragraph after the 2nd, then the new one has space although the 1st remains the same. If I add it before the 1st one then the new one doesn't have space and the previously 1st has! I used a new document with lipsum package for troubleshooting but in it every paragraph had the appropriate space. I have tried deleting and re-entering the paragraphs in my text but still have the same problem.

If I delete the listings package it seems that the problem fixes but I am not sure. It is completely weird! What is happening?

\documentclass[12pt]{article}

\usepackage
[
  top=0.7in,
  bottom=1.2in,
  left=0.8in,
  right=0.8in
]{geometry}


\usepackage{parskip}

\setlength{\parindent}{0cm}

\usepackage[fleqn]{amsmath}

\usepackage{unicode-math}

\usepackage{fontspec}

\usepackage[english,greek]{babel}


\setmainfont
[
  Ligatures=TeX,
  Extension=.otf,
  UprightFont=*,
  BoldFont=*Bold,
  ItalicFont=*It,
  BoldItalicFont=*BoldIt,
  Mapping=tex-text
]{GFSArtemisia}

\setsansfont[Mapping=tex-text]{GFSArtemisia.otf}


%Math fonts

\setmathfont{latinmodern-math.otf}
\setmathfont[range=\varnothing]{Asana-Math.otf}
\setmathfont[range=\int]{latinmodern-math.otf}

\usepackage{listings}

\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\usepackage{lipsum}

\begin{document}

\lstset
{
    basicstyle=\ttfamily,
    keepspaces=true,
    emph=
    {
    if, for, each, loop, do,
    then, return, function
    },
    emphstyle=\color{BrickRed}
}

\selectlanguage{english}

\section{Search}

\subsection{Subsection}

Text goes here.

\subsection{Uninformed Search Strategies}

More text goes here.

\subsubsection{Subsubsection}

\begin{lstlisting}[title={Source Cod}]
Text
\end{lstlisting}

\lipsum[1-2]

\paragraph{Paragraph1}Paragraph1 text

\lipsum[1-2]

\paragraph{Paragraph2}Paragraph2 text

\lipsum[1-2]

\paragraph{Paragraph3} Paragraph3

Text for Paragraph3

\end{document}
Mico
  • 506,678
Adam
  • 4,684
  • 2
    It's an old bug of listings: when it appears immediately after a sectional title, it doesn't reset a parameter that tells LaTeX a paragraph has been processed. – egreg Oct 28 '14 at 07:21
  • @egreg What can I do? And as it is old can't the maintainer fix it? – Adam Oct 28 '14 at 07:48
  • 1
    See http://tex.stackexchange.com/questions/165159/lstlisting-directly-after-section-start-removes-margin-before-next-section and http://tex.stackexchange.com/a/17011/4427 – egreg Oct 28 '14 at 08:05
  • Thank you very much! If you want you can post it as an answer. – Adam Oct 28 '14 at 08:08

0 Answers0