1

I use the mcode latex package available here:

I use:

\lstinputlisting{G:/PROJECT_and_SEMINARS/sms/v.1.39.a.1/sms.m}[caption={Source code of program: SMS. Version:1.39.a.1}][firstnumber = 1] 

command to import the matlab file. This imports and give me the code as is in the source file. However, my question is can any settings be made in mcode.sty so that the empty lines in the matlab source code be removed.. !! A solution to this will be very helpful

% LATEX DOCUMENT CODE:

\documentclass[08pt, a4paper, twoside]{Thesis}
\usepackage{framed}
\begin{document}

\begin{framed}
\lstinputlisting{.../sms.m}[caption={Source code of program: SMS. Version:1.39.a.1}]   [firstnumber = 1]
\end{framed}

\end{document}

MATLAB CODE:

% SMS.V.1.39_a:start date Sept.01.2013

%<><><><><><><><><><><><><><><><><><>
smc2()


% smc3()

% sfea1d()

% sfea2()
%<><><><><><><><><><><><><><><><><><>

% IMPROVEMENT TYPE ABBREAVIATION
% VM:VARIABLE MANAGEMENT  BR:BUG REMOVAL          NF:NEW FUNCTION               
% FE:FUNCTION EDIT        NC:NEW CAPABILITY       EH:ERROR HANDLING
% FF:FILE & FOLDER        SO:SPEED OPTIMIZATION   RD:RESULT DISPLAY
% FR:FUNCTION RENAME      MM:MEMORY MANAGEMENT
%<><><><><><><><><><><><><><><><><><>
jub0bs
  • 58,916

1 Answers1

1

See if this works for you:

\documentclass{article}
\usepackage{listings}
\makeatletter
\lst@AddToHook{OnEmptyLine}{\vspace{\dimexpr-\baselineskip+\smallskipamount}}
\makeatother
\usepackage{framed}
\begin{document}

\begin{framed}
\lstinputlisting[emptylines=1,caption={Source code of program: SMS. Version:1.39.a.1}]
       {my_matlab_code.m}
\end{framed}

\end{document}

Mathematica graphics

Reference: Ulrike Fischer post here

Nasser
  • 20,220
  • Thank you so much.. in the mean time, i had figured out a solution:
    \begin{framed}
    \lstinputlisting[showlines=false,emptylines=0,caption={sms},firstnumber = 1]{..../sms.m}
    \end{framed}
    
    – Sunil Anandatheertha Jan 06 '14 at 07:04
  • @SunilAnandatheertha Using emptylines=0 is preferable to the solution suggested in this answer. Why don't you post your own answer? – jub0bs Apr 28 '14 at 16:36