I have a problems with Listings in Latex. Breaklines is not working. Can anyone see what I have done wrong? Thank you.
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\small,
breakatwhitespace=false,
breakindent=1em,
breaklines=true,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
postbreak = \space,
}
\lstset{style=mystyle}
\begin{lstlisting}[language=Python, caption={Split of Data Set X into training and testing subsets.}, belowcaptionskip=10pt, label={lst:traintest}, alsoletter={()[].=}]
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, shuffle=False)
\end{lstlisting}
\documentclass[a4paper, twoside, openright, 12pt]{report}
\makeatletter
\def\cleardoublepage {\clearpage\if@twoside
\ifodd \c@page
\else \hbox{}\thispagestyle{empty}\newpage
\if@twocolumn\hbox {}\newpage \fi\fi\fi}
\raggedbottom
\makeatother
\usepackage{ramsstyle}
\usepackage{float}
\usepackage{parskip}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{shapes.multipart}
\usepackage{subfig}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage[font=small,skip=5pt]{caption}
\usepackage{chemformula}
\usepackage{booktabs}
\usepackage{commath}
\usepackage{array}
\usepackage{gensymb}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{lipsum}
\colorlet{shadecolor}{blue!20}
\usepackage{arydshln}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{inputenc}
\usepackage{notoccite}
\usepackage[bottom]{footmisc} %så fotnote på bunn av side
\usepackage[none]{hyphenat} %så ikke bindestrek
\emergencystretch 3em %så rett tekstslutt på sidene
\usetikzlibrary{shapes,arrows}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{fancyhdr}
\hypersetup{
colorlinks = true,
linkcolor = black,
citecolor = black,
urlcolor = black
}
\usepackage{listings}
\usepackage{color}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\usepackage{amsmath}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\small,
breakatwhitespace=false,
breakindent=1em,
breaklines=true,
keepspaces=true,
numbers=left,
numbersep=5pt, showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
postbreak = \space,
}
\lstset{style=mystyle}
\ProvidesPackage{notoccite}[2000/07/20]
\def\@starttoc#1{%
\begingroup
\@fileswfalse
\makeatletter
\@input{\jobname.#1}%
\endgroup
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
}
%%===================================
\begin{document}
\include{front}
\setcounter{page}{0}
\pagenumbering{roman}
\include{preface}
\include{abstract}
\include{sammendrag}
\tableofcontents
\listoffigures
\listoftables
\include{acronyms}
\include{nomenclature}
\pagenumbering{arabic}
\cleardoublepage
\setcounter{page}{1}
\fancyfoot{}
\pagestyle{fancy}
\lhead{}
\fancyfoot[LE,RO]{\thepage}
\include{chapter01}
\include{chapter02}
\include{chapter03}
\include{chapter04}
\include{chapter05}
% Include more chapters as required.
%%=========================================
\appendix
% Include more appendices as required.
%%=========================================
\bibliographystyle{IEEEtran}
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{refs}

style=mystyle. – epR8GaYuh Apr 26 '18 at 12:23y. One way to get longer lines could belinewidth=1.1\linewidthinside the the optional arguments of the listing environment, see this question for example. – epR8GaYuh Apr 26 '18 at 12:31hyphenatpackage is the issue. Try uncommenting it out from your code and compile. Or usehttoption instead ofnone. – Troy Apr 26 '18 at 12:59httinstead. It allows hyphens for typewriter fonts (which is used in listings). Unless you have words in typewriter fonts in your normal sentences? – Troy Apr 26 '18 at 13:08