1

I'm trying to get this

enter image description here

with this style enter image description here

but I'm getting the error ! Misplaced \omit. \multispan ->\omit \@multispan

Here is a MWE:

\documentclass{article}
\usepackage{listings,xcolor,etoolbox,lmodern}
\definecolor{verbgray}{gray}{0.9}
\newcommand*\prompt{}
\lstnewenvironment{sh}{
  \def\prompt{usuario@linux:\textasciitilde\$\space}
  \lstset{backgroundcolor=\color{verbgray},
    frame=single,
    framerule=.5pt,
    columns=fullflexible,
    escapechar=@
  }
}{}
\begin{document}
\begin{sh}
@\prompt\textbf{cal}
\begin{tabular}{c c c c c c c}
\multicolumn{7}{c}{Enero 2015}   \\
do & lu & ma & mi & ju & vi & sa \\
   &    &    &    &  1 &  2 &  3 \\
 4 &  5 &  6 &  7 &  8 &  9 & 10 \\
11 & 12 & 13 & 14 & 15 & 16 & 17 \\
18 & 19 & 20 & 21 & 22 & 23 & 24 \\
25 & 26 & 27 & 28 & 29 & 30 & 31 \\
\end{tabular}@
\end{sh}
\end{document}
  • 1
    listings is essentially a "verbatim" environent with some syntax highlighting, why are you putting tex markup for anything, especially a table in listings? – David Carlisle Jan 26 '15 at 21:50
  • I don't remember why I began doing these boxes with the listings environment but I can still change it. What environment would you recommend? – Arturo Jan 26 '15 at 21:59
  • You could either use listings as Jubobs suggests, using it as intended showing the verbatim output text, or if you want a tes-typeset table with a fancy box around it mdframed or tcolorbox for example will do all kinds of background colours and borders – David Carlisle Jan 26 '15 at 22:20
2

As David wrote in his comment, listings is mainly for verbatim contents. If you have this much markup in an "escape to LaTeX" within a listing, you're doing something wrong.

You're essentially hardcoding the output of the shell command cal 8 1973 into your lstlisting environment. Embedding it into a tabular within an escape to LaTeX seems convoluted and unnecessary. Why not simply

  • copy and paste the output into the lstlisting environment, and
  • set

    basicstyle = \ttfamily,
    columns    = fixed,
    

to get proper alignment? You can always use a different typewriter font, if you don't like the default one.

enter image description here

\documentclass{article}

\usepackage{listings,xcolor,etoolbox,lmodern}

\definecolor{verbgray}{gray}{0.9}
\newcommand*\prompt{}
\lstnewenvironment{sh}{
  \def\prompt{usuario@linux:\textasciitilde\$\space}
  \lstset{backgroundcolor=\color{verbgray},
    frame=single,
    basicstyle=\ttfamily,
    framerule=.5pt,
    columns=fixed,
    escapechar=@
  }
}{}

\begin{document}
\begin{sh}
@\prompt@cal 8 1973
    August 1973
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
\end{sh}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.