# Tag Info

## Hot answers tagged showexpl

11

\documentclass{article} \usepackage{fancyvrb} \def\showvrb#1{% \texttt{\detokenize{#1}} produces #1''% } \begin{document} I want a macro that produces something like \verb|$\bar\mathbf{x}$| produces $\bar\mathbf{x}$''. I want a macro that produces something like \showvrb{$\bar\mathbf{x}$}. \end{document} @Werner made a very similar answer ...

10

The code must be compiled externally. Loading the code of article.cls and all sorts of packages in the beamer run would lead to chaos. But theoretically if --shell-escape is active it is possible to trigger this external run on-the-fly during the compilation of the beamer run and then to include the resulting pdf with the graphic-option of showexpl. The main ...

8

Odd. For one reason or another, the showexpl package resets listing's xleftmargin keyval to 0pt if numbers=none (the default that you use). Since this isn't the behaviour you want, you might as well delete the offending code. Rather than rewriting the whole target command, you can use the etoolbox package's \patchcmd command to make the change in style. Just ...

7

This is not a 'fully worked up' solution for all cases, but I hope is enough of an answer to show how things can be done in a reasonably flexible way. The code in showexpl is pretty long, and so breaking into it to add the ability to use an external compilation is a bit tricky. Instead, I'm using some code I've adapted from the listings sources in my own ...

7

The problem is that the default setting of listings with "fixed columns" has a space 0.6em wide, while the characters in Computer Modern Typewriter are 0.5em wide. So you need only to add the options columns=fixed,basewidth=.5em, to \lstset. One can do without knowing the character width by saying something like \sbox0{\small\ttfamily A} ...

7

put the following into a file showexpl.cfg and save it in a directory where TeX will find it with kpsewhich (running texhash maybe needed). At least put it into the document directory. The file is automatically read by showexpl and redefines the output routine. \RequirePackage{multido} \newsavebox\SX@tempbox \renewcommand*\SX@resultInput{% ...

7


6

Using the explpreset key inside lstset, you can customize only the attributes for the LTXexampe environments, and this gives you the possibility to define different attributes for the lstlisting environment. A simple example illustrating this: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \usepackage{showexpl} \lstset{ ...

6

The explpreset key simply stores its value into the \SX@explpreset macro which is later used inside a local \lstset. This allows to define listings settings only for showexpl listings but not for other ones. The exact usage is as follows: showexpl.dtx, 2007/02/03 v0.3h, line 251: \lst@Key{explpreset}\relax{\def\SX@explpreset{#1}} by default it is empty: ...

5

The key width is only responsible for the formatted text, not the source code. To change the width of the typeset source code, modify your second LTXexample (without minipage) as follows: \begin{LTXexample}[explpreset={linewidth=0.5\linewidth},width=0.5\linewidth,pos=b]

5

You can work with a trick. The environment LTXexample uses the environment lstlisting. That means all options of the package listings are available. So you can start the displaying at line 2 and in the first line you can prevent the skip: \begin{LTXexample}[firstline=2] \abovedisplayskip0pt \begin{align} ax^2+bx+c & = 0\\ ax^2+bx & ...

5

Important remark According to the package author, as of version 2.71 of tcolorbox, the code for listings and changed several internal commands. The user interface is unchanged but the example code below with the internal macros may not work anymore. In any case, from version 2.71 on, the commands below are no longer needed, since the missing options have ...

5

The following preamble patch (using etoolbox) provides the desired output: \makeatletter \newlength{\parindent@save} \AtBeginDocument{\setlength{\parindent@save}{\parindent}} \patchcmd{\SX@put@code@result}% <cmd> {\SX@resultInput}% <search> {\setlength{\parindent}{\parindent@save}\SX@resultInput}% <replace> {}{}% ...

4

A different approach (I know it's not exactly what was requested and that it's not elegant, but could be used if this has to be done only a few times) is to place inside \LTXexample a minipage of bigger dimensions so as to accommodate the grid labels, and to use the firstline, lastline keys to "hide" these additional elements in the output: ...

4

This works for me: \documentclass{article} \usepackage{showexpl} \lstset{explpreset={numbers=none}} \begin{document} \begin{LTXexample} Hello World! \end{LTXexample} \end{document} You can read about the ęxplpreset parameter here. Update: if you specify explpreset={} the result will be the same (because this is the default)

4


4

define after loading package showexpl \makeatletter \renewcommand\SX@CodeArea[2]{% \setlength\@tempdima{#1}% \sbox\@tempboxa{\parbox\@tempdima{#2}}% \@tempdima=\dp\@tempboxa\raisebox{\dimexpr -\baselineskip-\fboxsep-\fboxrule-2pt}{\usebox\@tempboxa} \rlap{\raisebox{-\@tempdima}[0pt][0pt]{\SX@attachfile}}} \makeatother 2pt is the interlineskip

3

I am not using a patch method. Instead I add \hspace{\dimexpr\fboxsep+\fboxrule\relax} to \SX@CodeArea. I am not sure whether it is safe or not. But it produces the required output. \documentclass[10pt]{article} \usepackage[paperwidth=15cm,paperheight=6cm,margin=5mm,showframe=true]{geometry} \usepackage{xcolor} \usepackage{showexpl} \makeatletter % Add ...

3

When looking for the reason for the warning, that also results in special causes with an wrong reference number (for example listing 2.3 instead of listing 2.1) I found some older versions of showexpl, tried them and get the following result: with version 0.3j (current) the warning occurs with version 0.3i the warning disappears. The difference between ...

2

Starting with tcolorbox version 2.71 (2014/02/21), all missing comment outside listing e.a. options are implemented. A comment is considered as quite anything, especially a picture. For pictures, there is the new option image comment which simply sets a picture as comment. A comment outside a tcolorbox (left/right/below/above) is always considered as the ...

2

you'll get problems with frames when using a different color: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{xcolor} \usepackage{showexpl} \lstset{ basicstyle=\ttfamily\small, explpreset={moredelim=[is][\color{red}]{<}{>}}} \begin{document} \begingroup \catcode\<=\active \def<{} \catcode\>=\active \def>{} ...

2

I'll try to explain where the problem is located, and a possible workaround. Be warned, the workaround is very ugly! The problem is located at different places in the code of showexpl and listings packages (listings is used by showexpl). The way the package works is the following: it outputs the code into a intermediate file, then it uses listings package ...

2

I got a more elegant solution: Use preset option. \documentclass{article} \usepackage[a4paper,margin=25mm]{geometry} \usepackage{xcolor,showexpl} \lstset { language={[LaTeX]TeX}, basicstyle=\scriptsize\ttfamily, keywordstyle=\color{blue}\bfseries, backgroundcolor=\color{yellow!50}, numbers=none, frame=single, rframe=single, ...

1

you should use a good looking typewriterfont like `beramono' \documentclass{article} \usepackage[T1]{fontenc} \usepackage[scaled=0.82]{beramono} \usepackage{microtype} \usepackage{amsmath} \usepackage{showexpl} \usepackage{xcolor} \usepackage{multirow} % Newly added for 2nd example. \lstset{ backgroundcolor=\color{yellow}, ...

1

The issue here is that \loop reads everything till \repeat as argument and therefore doesn't allow verbatim environments like LTXexample: \loop: \long macro:#1\repeat ->\def \iterate {#1\relax \expandafter \iterate \fi }\iterate \let \iterate \relax You need to look for a different way to loop over it. Note that showexpl uses listings which allows for ...

1

When you use moredelim the delimiter are stripped already from the code when showexpl writes the code to a temporary file. (Check the tmp-file). So when the listing is printed the delimiters are simply not there. You can avoid it by using explpreset (don't use both moredelim and explpreset this leads to confusion.) \documentclass{article} ...

1


1

I wouldn't use a tabular for this. You will have problems with the page breaks. Also it will be difficult to adjust the spaces for the code and the output: sometimes you will probably have a small output but large code lines or the other way round. I would simply put the code and the output side by side with showexpl and use minipage+enumerate or something ...

Only top voted, non community-wiki answers of a minimum length are eligible