listing inserisce delle slash non richieste

  • Creatore
    Topic
  • #37388
    Up
    0
    Down
    ::


    ciao a tutti!

    sto usando il pacchetto listing per i listati in un linguaggio non standard, che ho definito così:

      \lstdefinelanguage{Xtend}
      {
      morecomment={/*}{*/},
      morecomment=[l]{//},% aggiunta la virgola mancante (egreg9)
      morestring=“,
      sensitive=true,
      morekeywords={
      private, create, extension, import, let, new, null, true, false, this, WARNING, ERROR, context
      }
      }

      \newcommand{\listxtend}{ \lstset{
      backgroundcolor=\color{lbcolor},
      tabsize=4,
      rulecolor=,
      numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,
      basicstyle=\scriptsize,
      upquote=true,
      aboveskip={1.5\baselineskip},
      columns=fixed,
      showstringspaces=false,
      extendedchars=true,
      breaklines=true,
      prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
      frame=single,
      showtabs=false,
      showspaces=false,
      showstringspaces=false,
      identifierstyle=\ttfamily,
      keywordstyle=\color[rgb]{0,0,1},
      commentstyle=\color[rgb]{0.133,0.545,0.133},
      stringstyle=\color[rgb]{0.627,0.126,0.941},
      language=Xtend,
      escapeinside={(*@}{@*)},
      }
      }

    Ora, quando nel codice inserisco delle etichette con:

      (*@\label{mia_etichetta}@*)

    mi appare nel codice un segno di slash (/) non richiesto…
    Da cosa può dipendere secondo voi?

    Grazie 1000! a presto!

Visualizzazione 4 filoni di risposte
  • Autore
    Risposte
    • #37389
      Up
      0
      Down
      ::

      ciao a tutti!

      sto usando il pacchetto listing per i listati in un linguaggio non standard, che ho definito così:

        \lstdefinelanguage{Xtend}
        {
        morecomment={/*}{*/},
        morecomment=[l]{//}
        morestring=“,
        sensitive=true,
        morekeywords={
        private, create, extension, import, let, new, null, true, false, this, WARNING, ERROR, context
        }
        }

        \newcommand{\listxtend}{ \lstset{
        backgroundcolor=\color{lbcolor},
        tabsize=4,
        rulecolor=,
        numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,
        basicstyle=\scriptsize,
        upquote=true,
        aboveskip={1.5\baselineskip},
        columns=fixed,
        showstringspaces=false,
        extendedchars=true,
        breaklines=true,
        prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
        frame=single,
        showtabs=false,
        showspaces=false,
        showstringspaces=false,
        identifierstyle=\ttfamily,
        keywordstyle=\color[rgb]{0,0,1},
        commentstyle=\color[rgb]{0.133,0.545,0.133},
        stringstyle=\color[rgb]{0.627,0.126,0.941},
        language=Xtend,
        escapeinside={(*@}{@*)},
        }
        }

      Ora, quando nel codice inserisco delle etichette con:

        (*@\label{mia_etichetta}@*)

      mi appare nel codice un segno di slash (/) non richiesto…
      Da cosa può dipendere secondo voi?

      Grazie 1000! a presto!

      L’esempio dobbiamo inventarlo noi?

      Ciao
      Enrico

    • #37390
      Up
      0
      Down
      ::


      ciao! Ecco un esempio (il comando listxtend è definito sopra):

      `\listxtend
      \begin{lstlisting}[label={cap1list2},caption={checks.chk}]
      import data;(*@\label{cap1list2:import}@*)

      context Attribute ERROR “Names must be more than one char long” : name.length > 1;

      context Entity ERROR “Names must be more than one char long” : name.length > 1;

      context Entity ERROR “Names of Entity attributes must be unique”:
      attribute.forAll(a1| attribute.notExists(a2| a1 != a2 && a1.name == a2.name ) );(*@\label{cap1list2:vincolo3}@*)
      \end{lstlisting}`

      output:

      `/ import data ; /
      2
      3 cont ext Attribute ERROR ” Names must be more than one char long ” : name . –
      length > 1 ;
      4
      5 cont ext Entity ERROR ” Names must be more than one char long ” : name . length > –
      1 ;
      6
      7 cont ext Entity ERROR ” Names of Entity attributes must be unique ” :
      8 attribute . forAll ( a1 j attribute . notExists ( a2 j a1 != a2 && a1 . name == a2 . –
      name ) ) ; /`

      come puoi vedere ci sono degli / indesiderati in corrispondenza delle etichette…

      grazie ancora! a presto!

    • #37391
      Up
      0
      Down
      ::


      L’errore sparisce quando aggiungi la virgola dopo “morecomment=[l]{//}”. Vedi pagina 21 della documentazione di listings:

      And if you encounter unexpected characters after selecting a language (or style), you have probably forgotten a different comma or you have given to many arguments to a key, for example, morecomment=[l]{–}{!}

      Aggiungo il colore rosso al tuo messaggio originale in modo che tu possa vedere dov’era l’inghippo.

      Ciao
      Enrico

    • #37392
      Up
      0
      Down
      ::

      L’errore sparisce quando aggiungi la virgola dopo “morecomment=[l]{//}”. Vedi pagina 21 della documentazione di listings:

      And if you encounter unexpected characters after selecting a language (or style), you have probably forgotten a different comma or you have given to many arguments to a key, for example, morecomment=[l]{–}{!}

      Aggiungo il colore rosso al tuo messaggio originale in modo che tu possa vedere dov’era l’inghippo.

      Ciao
      Enrico

      è vero mi ero perso una virgola e non me ne ero accorto! Grazie 1000! 🙂

    • #37393
      Up
      0
      Down
      ::


      scusami ancora, visto che ci sto azzardo un’altra domanda.. 🙂

      mi capita spesso che dei listati lunghi prima o dopo dei quali devo inserire un’immagine vengano spezzati dall’immagine stessa.. Non esiste un modo per impedire che un listato venga interrotto con figure o tabelle?

      Grazie 10000! 🙂 ciao

Visualizzazione 4 filoni di risposte
  • Devi essere connesso per rispondere a questo topic.

Go to top