سلام
با استفاده از بستههای lstlisting
و verbatim
بصورت زیر:
\documentclass[12pt,a4paper]{report}
\usepackage{listings,verbatim}
\begin{document}
\begin{lstlisting}[language=Matlab]
f=(1/(sqrt(2*pi)*dBW))*exp(-(w-w0)^2/(2*dBW^2));
%Source spectrum - Gaussian type
alpha=4.34*(pi*nc*W0*(2*An)/w)^2;
C=10^(-alpha/10);
%Sensitivity calculation
x1=sqrt(C*R1*R2)*(1-R1)*(1-C*R2)*sin(4*pi*n0*l/w);
x2=w*(1+C*R1*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w))^2;
x=x+8*pi*n0*alpha0*f*(x1/x2)*dw;
%Intensity calculation
y1=R1+C*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w);
y2=1+C*R1*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w);
y=y+alpha0*f*(y1/y2)*dw;
end
end
\end{lstlisting}
%
\begin{verbatim}
f=(1/(sqrt(2*pi)*dBW))*exp(-(w-w0)^2/(2*dBW^2));
%Source spectrum - Gaussian type
alpha=4.34*(pi*nc*W0*(2*An)/w)^2;
C=10^(-alpha/10);
%Sensitivity calculation
x1=sqrt(C*R1*R2)*(1-R1)*(1-C*R2)*sin(4*pi*n0*l/w);
x2=w*(1+C*R1*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w))^2;
x=x+8*pi*n0*alpha0*f*(x1/x2)*dw;
%Intensity calculation
y1=R1+C*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w);
y2=1+C*R1*R2-2*sqrt(C*R1*R2)*cos(4*pi*n0*l/w);
y=y+alpha0*f*(y1/y2)*dw;
end
end
\end{verbatim}
\end{document}
توضیحات:
https://www.sharelatex.com/learn/Code_listing
https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings
توجه: اگر در متن باشد:
\documentclass[12pt,a4paper]{report}
\begin{document}
a\textasciicircum b
a\^{}b
\end{document}
خروجی: