Re: Ambiente per inserire codice LaTeX con di fianco il typeset

#10078
lorenzo.pantieri
Partecipante
    Up
    0
    Down
    ::


    Ciao Andrea, ho provato il codice che mi hai segnalato. Vorrei sapere se è possibile inserire uno sfondo grigio nel codice LaTeX (e non nel corrispondente typeset). Se scrivo:
    `\documentclass[12pt]{article}
    \usepackage[T1]{fontenc}
    \usepackage[applemac]{inputenc}
    \usepackage[writefile]{listings}
    \usepackage[italian]{babel}
    \usepackage{xcolor}

    \lstset{extendedchars} % important
    \makeatletter
    \lstnewenvironment{sidebyside}{%
    \global\let\lst@intname\@empty
    \setbox\z@=\hbox\bgroup
    \setkeys{lst}{language={},style={},basewidth=0.51em,%
    basicstyle=\small\ttfamily,backgroundcolor=\color{lightgray}
    } %
    \lst@BeginAlsoWriteFile{\jobname.tmp}%
    }{%
    \lst@EndWriteFile\egroup
    \ifdim \wd\z@>.5\linewidth %%% alternative?
    \begin{center}%
    \hbox to\linewidth{\box\z@\hss}%
    \end{center}%
    \leavevmode \catcode`\^^M=10\relax
    \input{\jobname.tmp}%
    \else
    \begin{center}%
    \begin{minipage}{0.45\linewidth}%
    \hbox to\linewidth{\box\z@\hss}%
    \end{minipage}%
    \qquad
    \begin{minipage}{0.45\linewidth}%
    \leavevmode \catcode`\^^M=10\relax
    \input{\jobname.tmp}%
    \end{minipage}%
    \end{center}%
    \fi
    }
    \makeatother
    \begin{document}
    Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo
    Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo
    \begin{sidebyside}
    \textit{Andrea} è il mio nome,
    \textit{Lorenzo} è il tuo.
    \LaTeX\ è il nostro programma
    preferito. Esempio con il
    pacchetto listings.
    \end{sidebyside}
    Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo
    Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo Testo
    \end{document} `
    lo sfondo grigio viene inserito sia nel codice LaTeX sia nel corrispondente typeset.

    Mi piacerebbe sapere, inoltre, se è possibile fare il viceversa (cioè inserire lo sfondo nel typeset, ma non nel codice LaTeX).

    Grazie mille!

    Ciao,
    L.

    Go to top