Combina dos códigos de codehigh

Combina dos códigos de codehigh

Me está costando mucho intentar tener un código que proporcione el código completo y su resultado, uno al lado del otro.

Por favor ayuda.

Gracias.

ingrese la descripción de la imagen aquí

    \documentclass{article}

\usepackage{codehigh}
\usepackage{amsmath}
\usepackage{tcolorbox}

\tcbset{sharp corners, boxrule=0.5pt, colback=red9}
\colorlet{highback}{azure9}

\CodeHigh{language=latex/table,style/main=highback,style/code=highback}
\NewCodeHighEnv{code}{style/main=gray9,style/code=gray9}
\NewCodeHighEnv{demo}{style/main=gray9,style/code=gray9,demo}

\begin{document}

\begin{demo}
$\sqrt{2x+5}$
\end{demo}

\begin{codehigh}
\documentclass{article}
\usepackage{amsmath}
$\sqrt{2x+5}$
\end{document}
\end{codehigh}

\end{document}

Respuesta1

Como nunca lo había hecho antes, lo probé.

  • tikznode lowerponer la parte inferior en una caja

Código

\documentclass{article}
%https://tex.stackexchange.com/questions/706438/combine-two-codes-of-codehigh
\usepackage{amsmath}
\usepackage{ninecolors}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\tcbuselibrary{skins}

\begin{document}
\newlength{\lengthformule}
\settowidth{\lengthformule}{$\sqrt{2x+5}$}

\begin{tcblisting}{
        sharp corners,
        boxrule=0.5pt,
        colback=gray9,
        sidebyside,
        righthand width=\the\lengthformule,
        lower separated=false,
        tikznode lower={inner sep=2pt,draw=red,fill=yellow}
    }
    $\sqrt{2x+5}$
\end{tcblisting}

\begin{tcblisting}{
        colback=azure9,
        colframe=azure4,
        listing only,
        %enhanced,
    }
    \documentclass{article}
    \usepackage{amsmath}
    \begin{document}
    $\sqrt{2x+5}$
    \end{document}
\end{tcblisting}

\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

Siguientembertola sugerencia de(buen paquete por cierto)Aquí hay algunas líneas con showexpl:

resultado

\documentclass{article}
\usepackage{showexpl}
\usepackage{amsmath}

\begin{document}
    Normal
     \begin{LTXexample}
        $\sqrt{2x+5}$
        
        $\sqrt{2x - 5}$
     \end{LTXexample}
    
    pos=r
     \begin{LTXexample}[pos=r]
        $\sqrt{2x+5}$
     \end{LTXexample}
    
    pos=l
     \begin{LTXexample}[pos=l]
        $\sqrt{2x+5}$
     \end{LTXexample}
    
    pos=o
     \begin{LTXexample}[pos=o]
        $\sqrt{2x+5}$
     \end{LTXexample}
     
     pos=i
     \begin{LTXexample}[pos=i]
        $\sqrt{2x+5}$
     \end{LTXexample} 
\end{document}

información relacionada