1

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.

Aradnix
  • 3,735
  • 2
  • 20
  • 43
  • 1
    @Aradnix: You need \verb? Or isn't listings allowed? –  Jun 14 '15 at 09:12
  • 1
    I would recommend you use listings for the LaTeXcode and\tikzmarkto mark the appropriate points in the LaTeX code, and then usetikz` 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 09:44
  • @Alenanno interesting, but is not what I'm looking for. – Aradnix Jun 14 '15 at 16:03
  • @ChristianHupfer can be listings also, but \verb is a simpler option. In fact my problem isn't with the code but with the other column, where I need, in this case, add an indication with braces. – Aradnix Jun 14 '15 at 16:12
  • 1
    @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. –  Jun 14 '15 at 16:18
  • @PeterGrill It's a good idea, perhaps the best choice except that I don't know how use (yet) TikZ well and I have no idea how to do what you say. Otherwise maybe your suggestion is complemented with Christian. – Aradnix Jun 14 '15 at 16:28

1 Answers1

2

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}

enter image description here

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:

enter image description here

Zarko
  • 296,517
  • 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
  • 1
    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: usemultirowpackage and enlarge}or draw it with tikz inoverlay` 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
  • 1
    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