This site will go down shortly. If you need any help, then please subscribe to The Persian TeX discussion mailing list
ask now - it's free

Most popular questions within the last 3 days

Most active Members
this month:
    0 votes
    63 views

    How can I typeset the following MATLAB code verbatim?

    % A MATLAB version of the NAG subroutine C02AFZ
    % for computing the zeros of polynomials using
    ndeg = length(f) - 1; %degree of polynomial
    n = ndeg; N = n+1;
    ihalf = 0; ispir=0; iter = 0;
    cauchy = 0; %Region containing smallest
    
    asked by (220 points)
    edited by

    Please always provide a minimal (La)TeX code whenever you ask any questions.

    1 Answer

    0 votes
     
    Best answer

    You can use the verbatim environment to typeset any verbatim code. So

    \documentclass{article}
    \usepackage{xepersian}
    \settextfont{Yas}
    \begin{document}
    \begin{LTR}
    \begin{verbatim}
    % A MATLAB version of the NAG subroutine C02AFZ
    % for computing the zeros of polynomials using
    ndeg = length(f) - 1; %degree of polynomial
    n = ndeg; N = n+1;
    ihalf = 0; ispir=0; iter = 0;
    cauchy = 0; %Region containing smallest
    \end{verbatim}
    \end{LTR}
    \end{document}
    

    will do. The extra LTR environment is necessary to typeset the verbatim code left to right.

    answered by (3.1k points)
    selected by

    What's the difference between using the LTR environment here instead of the latin environment?

    In general, the latin environment is the same as the LTR environment with few exceptions

    • Counters alph and Alph gives you lowercase and uppercase English Alphabets, respectively;
    • The script is latin;
    • The font is latin.

    In this special case, it does not make any difference; you can either use the LTR or the latin environment. However, using the latin environment seems to be redundant as the verbatim environment font is typewriter.

    ...