Tag Info

New answers tagged

7

I'm sure you'll appreciate this devious trick: \documentclass[12pt]{article} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{fancyvrb} %A more wedge-like caret for use in code. \newcommand\pow{% \hspace{-1pt}% \raisebox{-1pt}{\scalebox{1.2}{\textsf{\textasciicircum}}}% \hspace{-1pt}% } \newcommand{\makehatpow}{% \begingroup\lccode`~=`^ ...


3

You need \meaning, something like \documentclass{article} \def\foo#1>{} \newcommand\showcase[1]{% \def\tmp{#1}% \texttt{\expandafter\foo\meaning\tmp} #1} \begin{document} \showcase{$\alpha$} \end{document}


5

Adapting from code in this answer \documentclass[12pt]{article} \usepackage[margin=1cm]{geometry} \usepackage{fancyvrb,xcolor} \usepackage{lipsum} % just for the example \newsavebox{\FVerbBox} \newenvironment{FVerbatim} {\VerbatimEnvironment \begin{center} \begin{lrbox}{\FVerbBox} \begin{minipage}{5.8in} \begin{Verbatim}} {\end{Verbatim} ...


0

Ok, I managed to get somewhere, but not sure how correct it is. Basically, it's all about setting basewidth=, but to a correct value, which I've obtained by using \widthof from package calc. Now, the problem is that we must have an expandable macro for basewidth= - and also, I think when basewidth= is processed, the {lstlisting} environment still doesn't ...


3

Ok, I didn't find the answer to my question, but this workaround is just working: \lstset{basicstyle=\selectlanguage{english}\ttfamily} This switch my language (and font) to English everywhere I call \lstinline and \begin{lstlisting} ... \end{lstlisting}, and switch back to my main language when the scope end. So I no longer need those \pretocmd or ...


1

A bit late to the party, but this fix to http://tex.stackexchange.com/users/243/topskip's answer does the job: in response to question in comments: In topskip's answer Hello World is still written to the pdf file, which is not typically what one would want. So I've taken his answer and made the change that if the line read does not contain "\end{foobar}" ...


3

Frames containing verbatim material should be declared fragile; also you don't really want that dramatic indentation, which will be kept in the listing. \documentclass{beamer} \usepackage{alltt} \begin{document} \begin{frame}[fragile] \frametitle{Beispiel Mergesort} \begin{alltt} mergesort :: (Ord a, Trans a) => [a] -> [a] mergesort [] = [] ...


0

I found the solution, and I feel a bit stupid. Because I was migrating from a different template, the "listings" package was actually not included! Everything started working smoothly again when adding: \usepackage{listings} I wonder, though, why I did not get any "undefined control sequence" or similar errors. That would have pointed me to the mistake in ...


1

Please always provide a complete example document, Thanks to Jesse, I stole this one from the other answer. You can use \small or any other font size to reduce the size of the verbatim: \documentclass{article} \begin{document} \vspace*{-3cm} Before: \begin{verbatim} pred3(s11,s17,s11,s19,s10). pred3(s11,s17,s11,s19,s10). pred3(s11,s17,s11,s19,s10). ...


2

Would this be close to what you seek? The proposed solution utilizes fancyvrb package where xleftmargin/xrightmarin (dimension) commands for indentation to add at the start/end of each line (Default: 0pt—no left/right margin) is readily available. However, this solution also defines myindent macro taking one length argument for manual indentation within ...


2

You can use the accsupp package to set the text that is copied from the document separately from what the document displays. For example, you could use \textasciitilde as your tilde in a command \actualtilde with \documentclass{article} \usepackage{accsupp} ...


2

If you use \textasciitilde it will use a tilde character in ascii position if \usepackage[T1]{fontenc} is used. in the default OT1 encoding it uses a tilde accent over nothing as the fonts do not contain an ascii spacing tilde character (other than cmtt as used in verbatim) The actual appearance depends on the font but in all cases it is a single ...


10

For pdf output you can use the minted package. This produces a nicely formatted and coloured PDF file for you. As described in the minted package documentation, you have to install Pygments and run (pdf)latex with the -shell-escape option. To use this approach to produce html you also need to pass the -shell-scape option to htlatex. You can do this using ...



Top 50 recent answers are included