0

How do I remove (or change) the formatting for end on line 8 while not removing it for end that closes the for-loop?

enter image description here

\documentclass{article}
\usepackage{verbatim}       % code
\usepackage{listings}       % code
\usepackage{xcolor}         % color
\usepackage{color}          % bgrnd

\definecolor{light-gray}{gray}{0.95} 
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Matlab,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  identifierstyle=\color{black},
  basicstyle={\small\ttfamily},
  numbers=left,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}


\begin{document}

\lstset{language=Matlab,
    morekeywords={matlab2tikz},
    morekeywords=[2]{1}, keywordstyle=[2]{\color{black}},
    numbers=left, 
    numberstyle={\tiny \color{black}},
    numbersep=9pt,
    emph=[1]{for,end,break},emphstyle=[1]\color{blue},
}

\begin{lstlisting}[backgroundcolor=\color{light-gray},deletekeywords={and,using,new}]
disp('Starting')

variable = 5;
x = linspace(40000,140000,variable); % motor
    
for k = 1:x 
    sim("file")
    a = b(end); % comment 
end

%% comment
disp('Finished!')
\end{lstlisting}


\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.