![Línea de código tikzexample ajuste automático en Beamer](https://rvso.com/image/305742/L%C3%ADnea%20de%20c%C3%B3digo%20tikzexample%20ajuste%20autom%C3%A1tico%20en%20Beamer.png)
En Beamer, si demostramos algún código con el paquete tkzexample (consulteeste ejemplo), a veces el código se quedará sin el cuadro de marco.
- ¿Es posible hacer que se ajuste automáticamente si la línea de código es demasiado larga?
- La distancia entre el segundo y el tercer diagrama no parece igual.
código de ejemplo:
\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage{tkzexample}
\colorlet{graphicbackground}{red!10!white}%
\colorlet{codebackground}{blue!10!white}%
\colorlet{codeonlybackground}{blue!10!white}
\begin{document}
\begin{frame}[fragile]{tikz example}
\begin{tkzexample}[width=2cm]
\begin{tikzpicture}
\draw (0,0) node[circle,
shade,
ball color=orange,
minimum size=2cm]{};
\end{tikzpicture}
\end{tkzexample}
\begin{tkzltxexample}[line frame width=0pt]
\begin{tkzexample}[width=1cm]
\tikz[baseline]
\node [circle,line width=1ex,draw=blue,fill=blue]
{\textcolor{white}{\Large{TikZ}}};
\end{tkzexample}
\end{tkzltxexample}
\begin{tkzexample}[width=1.7cm]
\tikz[baseline]
\node [circle,line width=1ex,draw=blue,fill=blue]
{\textcolor{white}{\Large{TikZ}}};
\end{tkzexample}
\end{frame}
\end{document}
Producción:
Respuesta1
Si no te importa cambiar atcolorbox
paquete en lugar de tkzexample
usted puede hacer algo como:
tcolorbox
utiliza listings
(o minted
) para la composición tipográfica de código y todas sus opciones (estilo de fuente, numeración de líneas, líneas de ruptura, ...) se pueden aplicar a las partes del listado. Lo he mirado tkzexample
y creo que no lo usa.
Por el momento no sé cómo agregar un color de fondo a TiKZ
las figuras. Lo sabremos, cambiaremos text outside listing
con text side listing
pero en este caso no hay separación entre el código y los cuadros de resultados.
\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\newtcblisting{tkzexample}[1][]{text outside listing, fonttitle=\bfseries, bicolor, colback=blue!10!white, colbacklower=red!10!white, colframe=black, sharp corners, frame hidden, size=tight, #1}
\newtcblisting{tkzltxexample}[1][]{listing only, fonttitle=\bfseries, bicolor, colback=blue!10!white,colbacklower=red!10!white, colframe=black, sharp corners, frame hidden, size=tight, #1}
\begin{document}
\begin{frame}[fragile]{tikz example}
\begin{tkzexample}[lefthand width=2cm]
\begin{tikzpicture}
\draw (0,0) node[circle,
shade,
ball color=orange,
minimum size=2cm]{};
\end{tikzpicture}
\end{tkzexample}
\begin{tkzltxexample}[listing only]
\begin{tkzexample}[width=1cm]
\tikz[baseline]
\node [circle, line width=1ex, draw=blue, fill=blue]
{\textcolor{white}{\Large{TikZ}}};
\end{tkzexample}
\end{tkzltxexample}
%
\begin{tkzexample}[lefthand width=1.5cm]
\tikz[baseline]
\node [circle, line width=1ex, draw=blue, fill=blue]
{\textcolor{white}{\Large{TikZ}}};
\end{tkzexample}
\end{frame}
\end{document}