Tag Info

Hot answers tagged

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 ...


10

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} ...


9

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 ...


8

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

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

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: ...


7

Because showexpl is based on the listings package, most of the latter's features, including the literate key should, in theory, work out of the box. For some reason, though, defining the literal replacements globally, like so \lstset { literate= *{\{}{{\textcolor{blue}{\{}}}{1} {\}}{{\textcolor{blue}{\}}}}{1}, } seems to break showexpl, which ...


7

This is a package bug but easy to fix, the redefinition of table and figure should end with \par not with nothing. \documentclass{article} \usepackage{showexpl} \makeatletter \renewcommand*\SX@@preset{% \renewcommand\documentclass[2][]{\SX@eat@version}% \renewcommand\usepackage[2][]{\SX@eat@version}% \renewenvironment{document}{}{}% ...


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{ ...


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

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)


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 "simple" workaround using TikZ: \documentclass[12pt]{book} \usepackage[a4paper,showframe=true]{geometry} \usepackage{xcolor} \usepackage{tikz} \usepackage{accsupp} \newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}} \usepackage{showexpl} \makeatletter \renewcommand*\SX@put@r[3]{% \setlength\@tempdimc{\linewidth-#1-\SX@hsep}% ...


4

showexpl has to write the code to a temporary file. It uses an internal command of listings for this. But accent doesn't survive if you use the literate option too. Put the code in some external file and then use \LTXinputExample{test-code}


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

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

Although it is possible (see below), I'm not sure why you would want to change the syntax of the graphic key... With the syntax you suggest, what used to be an optional argument will become mandatory. Are you sure that's really what you want? First, to make the graphic key accept its arguments as graphic={option}{path/to/image} instead of ...


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 ...


3

Maybe a small step in the right direction: instead of producing output, we define two commands \LTXlastexample{in/out}put that still need the width they are to be typeset into. This will require you to output both parts before you issue the next LTXexample, and I've not given much thought to whether it will work beyond my example case, in a spirit of "what ...


3

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 ...


3

See also How can I color braces in showexpl? The problem is that showexpl, texcl, moretexcs, morekeyword, and literate are not compatible in some ways. So just try out everything you think of. \documentclass{article} \usepackage{xcolor,showexpl} \lstset{language=[LaTeX]Tex,basicstyle=\ttfamily,texcsstyle=*\color{blue}} ...


2

try ... \makeatletter \let\SX@I\SX@resultInput \def\SX@resultInput{\centerline{\SX@I}} \makeatother \begin{document} \LTXinputExample[pos=t,style=PSTricks,graphic={[scale=1]"diagram"}]{diagram.tex} \end{document}


2

Taken from Herbert's another answer (click) several decades ago and I modified to meet my requirement. But honestly I am not sure whether or not it is safe for long-term use. \documentclass[dvipsnames,border=12pt,preview]{standalone} \usepackage{xcolor} \usepackage{showexpl} \usepackage{accsupp} ...


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, ...


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 ...



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