# How to create LaTeX example codes using verbatim and large braces?

I read this question it's useful but isn't exactly what I need.

My problem consists in create an array, table or something like that with two columns. In the left one I need to put LaTeX code with \verb or verbatim, but in the right instead of the result, I need to and braces for explain each part of the another column.

My MNWE:

    \documentclass[twoside,symmetric]{tufte-handout}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,mexico]{babel}
\usepackage{array{
\begin{document}

\begin{tabular}{lc}
\verb+
\documentclass[options]{class}
+ & \\
\verb+
\usepackage[options]{package}
+ & \left. \right\} preamble \\
$\vdots$ & \\
\verb+
\begin{document}
+ & \\
$\vdots% & \left. \right\} body \\ \verb+ \end{document} + & \\ \end{tabular} \end{document}  I hope you understand what I'm trying to do. Is simple a kind of diagram about the basic LaTeX structure, but I don't know how to build it. • Would something like this do it for you? – Alenanno Jun 14 '15 at 8:52 • @Aradnix: You need \verb? Or isn't listings allowed? – user31729 Jun 14 '15 at 9:12 • I would recommend you use listings for the LaTeX code and \tikzmark to mark the appropriate points in the LaTeX code, and then use tikz to do the drawing of the braces and the annotations. This way you can separate the code from the annotation and have more flexibility and readability of the original code. – Peter Grill Jun 14 '15 at 9:44 • @Alenanno interesting, but is not what I'm looking for. – Aradnix Jun 14 '15 at 16:03 • @Aradnix: Yes, I see -- I am not sure this is possible with listings in a easy way. I think Zarko's answer is quite good. – user31729 Jun 14 '15 at 16:18 ## 1 Answer You have some errors in your WME. I only correct them and use article and instead of tufte-handout (I havent instaled it in my MikTeX). Also I comment the babel for the same reason: \documentclass[twoside,symmetric]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} %\usepackage[spanish,mexico]{babel} \usepackage{array} \begin{document} \begin{tabular}{ll} \verb+\documentclass[options]{class}+ & \\ \verb+\usepackage[options]{package}+ &$\bigg\}$preamble \\$\vdots$& \\ \verb+\begin{document}+ & \\$\vdots$&$\bigg\}$body \\ \verb+\end{document}+ & \end{tabular} \end{document}  Addendum: From comment of OP follows, that curly braces should spanned more rows: This can be achieved on various way, I will limit myself to use of multirow: \documentclass[twoside,symmetric]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} %\usepackage[spanish,mexico]{babel} \usepackage{multirow} \begin{document} \begin{tabular}{ll} \verb+\documentclass[options]{class}+ & \\ \verb+\usepackage[options]{package}+ & \multirow{2}{*}{$\bigg\}$preamble}\\$\vdots$& \\ \verb+\begin{document}+ & \multirow{3}{*}{$\left.\rule{0em}{5.5ex}\right\}$body}\\$\vdots\$                                &   \\
\verb+\end{document}+                   &   \\
\end{tabular}
\end{document}


which gives:

• Thanks for the suggestion, I know about the errors, that's the reason why I called MNWE (Minimal NOT Working Example) because it was an sketch about my idea. Now my doubt with your solution is how to enlarge the braces to fit exactly with the preamble and body sizes in the other column. I mean, how to fit them since \documentclass line until the vertical dots in the first case? – Aradnix Jun 14 '15 at 15:55
• About sizes of your braces: do you like that they span for example begin{document} ... \end{document}? If this is case, two solution cross my mind: use multirow package and enlarge } or draw it with tikz in overlay option. – Zarko Jun 14 '15 at 16:12
• I see from all the previous comments that I have to find out how to get it with TikZ. – Aradnix Jun 14 '15 at 16:33
• Hm, seems to be with `multirow beter solution,. See, eddit of my answer – Zarko Jun 14 '15 at 17:06
• Perfect, exactly what I need for now. Thanks for the helping. However I think it is urgent to learn well TikZ to do these things better soon. – Aradnix Jun 14 '15 at 17:21