I'm thinking of creating a query material so that I can see the compilation result with your code just below.
As I'm starting in this TEX world, I do not want to accumulate multiple TEX files on my system. I'd rather create a PDF that has everything I'm studying.
I was advised to use the tcolorbox
package, but I do not think I did anything right.
I tried to compile the code below, but I did not succeed.
\documentclass{article}
\usepackage{tcolorbox}
\usepackage[listings]{tcolorbox}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength{\PreviewBorder}{10pt}%
%%%>
\usetikzlibrary{calc}
\usepackage{amssymb}
%----------------------------------------------------------------------------------------
% Definition in the preamble
%----------------------------------------------------------------------------------------
\tcbset{
texexp/.style={colframe=red!50!yellow!50!black, colback=red!50!yellow!5!white,
coltitle=red!50!yellow!3!white,
fonttitle=\small\sffamily\bfseries, fontupper=\small, fontlower=\small},
example/.style 2 args={texexp,
title={Example \thetcbcounter: #1},label={#2}},
}
\newtcblisting{texexp}[1]{texexp,#1}
\newtcblisting[auto counter,number within=section]{texexptitled}[3][]{%
example={#2}{#3},#1}
\newtcolorbox[use counter from=texexptitled]{texexptitledspec}[3][]{%
example={#2}{#3},#1}
\begin{document}
\begin{tikzpicture}
\draw[dashed,color=gray] (0,0) arc (-90:90:0.5 and 1.5);
\draw[semithick] (0,0) -- (4,1);
\draw[semithick] (0,3) -- (4,2);
\draw[semithick] (0,0) arc (270:90:0.5 and 1.5); \draw[semithick] (4,1.5) ellipse (0.166 and 0.5);
\draw (-1,1.5) node {$\varnothing d_1$};
\draw (3.3,1.5) node {$\varnothing d_2$};
\draw[|-,semithick] (0,-0.5) -- (4,-0.5);
\draw[|->,semithick] (4,-0.5) -- (4.5,-0.5);
\draw (0,-1) node {$x=0$};
\draw (4,-1) node {$x=l$};
\end{tikzpicture}
\end{document}
And just below the PDF template I want to create:
EDIT
I was able to advance a little more with the help of Christian-Hupfer.
My attempt:
\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcblisting}{% Some options here
}
\newcommand{\codewithoutput}[1]
{
\begin{tikzpicture}
\draw[dashed,color=gray] (0,0) arc (-90:90:0.5 and 1.5);
\draw[semithick] (0,0) -- (4,1);
\draw[semithick] (0,3) -- (4,2);
\draw[semithick] (0,0) arc (270:90:0.5 and 1.5); \draw[semithick] (4,1.5) ellipse (0.166 and 0.5);
\draw (-1,1.5) node {$\varnothing d_1$};
\draw (3.3,1.5) node {$\varnothing d_2$};
\draw[|-,semithick] (0,-0.5) -- (4,-0.5);
\draw[|->,semithick] (4,-0.5) -- (4.5,-0.5);
\draw (0,-1) node {$x=0$};
\draw (4,-1) node {$x=l$};
\end{tikzpicture}
}
\codewithoutput{\LaTeX}
\end{tcblisting}
\end{document}
tcolorbox
and its listings.tcolorbox
,listings
andcode
andcode output