# Tag Info

0

I adapted the example form TEX \documentclass{article} \usepackage{listings} \usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white \definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue \definecolor{mylilas}{RGB}{170,55,241} \lstset{language=Matlab,% %basicstyle=\color{red}, breaklines=true,% ...

0

We got the above image with the assistance of array package, you can change the width of columns as you like % \usepackage{array} \begin{center} \begin{tabular}{p{3.9cm}|p{3.9cm}} \begin{lstlisting} while (x > 0) do x++; \end{lstlisting} & \begin{lstlisting} x = 0; \end{lstlisting} \end{tabular} \end{center}

1

Using a Unicode-aware engine If changing engine to either XeTeX or LuaTeX is an option, then you can remove the literate stuff from the \lstset, remove inputenc and add fontspec. With those modifications it just works. Note that in the code below I set belowskip and aboveskip to 0pt where necessary to remove the gap between the different listings, rather ...

2

It works if you specify exactly the same settings i.e. none: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \usepackage{fullpage} \newcommand{\grayScale}{0.95} % Can change the gray level here \definecolor{codeBackground}{rgb}{\grayScale ,\grayScale ,\grayScale} \definecolor{forestGreen}{rgb}{0.13,0.55,0.13} \begin{document} % Using ...

0

Based on previous answers and comments, here is the solution I use with Pandoc 1.15. Specific command line options : --listings -H header.latex Specific header.latex file content : \BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} \AfterEndEnvironment{lstlisting}{\end{minipage}\par\addvspace{\topskip}}

1

If you are able to settle for verbatim code that is not syntax highlighted, and which does not require page breaking, you could place it in a verbatimbox prior to entering your newly defined solution environment. Of course, by that point, it is in a box, and not available as text. \documentclass[10pt]{book} \usepackage{environ} %\usepackage{listings} ...

3

beamer has the columns environment, makes sense to use that I think. Note that you need the [fragile] option to the frame in order to use verbatim and the like. \documentclass{beamer} \begin{document} \begin{frame}[fragile] \begin{columns}[t] \column{0.5\textwidth} \begin{verbatim} SELECTION test1 JET_N 25000 >= 1 JET_N 25000 >= 2 JET_N 25000 >= ...

0

You cannot nest floating environments; \marginpar's are floats. You can define a command to mimic a marginpar by making it non-floating and invisible: \documentclass{article} \usepackage{listings,calc} \lstset{language=C++,numbers=left,escapeinside={(*@}{@*)}} \newcommand*{\marginnote}[1]{% \makebox[0pt][l]{% ...

1

Looks like a bug of listings package, because no line breaks should be produced unless you explicitly request them with breaklines=true. Moreover, if you use showspaces=true, then line breaks are not produced (but you have all spaces visible as ␣, of course). This suggested me the following hack: use showspaces=true, but redefine the "visible space" to be ...

2

You can use the verbatim package to define a new environment that defines a character to enclose the footnote text. \documentclass{article} \usepackage{verbatim} \textheight=3cm % just not to waste space \newcommand{\vfchar}[1]{% % the usual trick for using a "variable" active character \begingroup\lccode~=#1 \lowercase{\endgroup\def~##1~}{% % ...

4

Here is a version without the use of packages (i.e., works in plain verbatim environment). I make ? (or any char of your choosing) active and employ ! (or any char of your choosing) as a delimiter. With this syntax, ?!My footnote! is the equivalent of \footnote{My footnote}. \documentclass{article} \textheight=1.5in\relax% FOR THIS MWE ONLY ...

11

listings provides the possibility to escape to LaTeX inside a listing, see section 5.12 Escaping to LaTeX of the manual for details. The basic idea is to set an escapechar which switches to LateX and back: \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[basicstyle=\ttfamily,columns=fullflexible,gobble=2,escapechar=ß] ...

6

You can do this with \newminted command \documentclass{article} \usepackage{minted} \newminted[lstlisting]{scala}{} \begin{document} \begin{lstlisting} #include <stdio.h> #define N 10 /* Block * comment */ int main() { int i; // Line comment. puts("Hello world!"); for (i = 0; i < N; i++) { puts("LaTeX is also ...

2

I approximated it using lhs2tex’s polytable package directly, and I now get the desired output with: \begin{acode} \> !let t1 = foo x \\ \> !in \> !let g x = \> !if x > 10 \\ \> \> \> !then \> t1 \\ \> \> \> !else \> !let t2 = bar x \\ \> \> \> \> !in ...

2

You want it centered and using the counter for equations, so the easiest thing would be to use an equation and write it inside \hbox with the desired format: \documentclass{article} \usepackage{amsmath} \usepackage{listings} \lstset{basicstyle=\ttfamily} \begin{document} some test text and some more text and some more text and some more text and some ...

1

Use the escapeinside option: \documentclass{article} \usepackage{listings} \lstset{basicstyle=\ttfamily,escapeinside='} \newcounter{cnt} \newcommand\Label[1]{\hfill\refstepcounter{cnt}(\thecnt)\label{#1}} \begin{document} \begin{lstlisting} solve(UEqn == - fvc::grad(p)); \Label{foo}' \end{lstlisting} \begin{lstlisting} solve(UEqn == - fvc::grad(p)); ...

2

Here I use my numberedblock package, that allows labeled code blocks that can be referenced. I use brackets instead of parens, so as not to confuse with equation numbering. With its built-in macros and environments, one can only do code blocks of fixed indent. However, by employing some additional code, centering can be achieved. \documentclass{article} ...

1

We can add degree circle in lyx: In text, with "insert" then "special character" then "symbols..." Then "Latin-1 Supplement" and click on "degree circle", there are 2 size degreeCircle in Latin-1 supplement category. In formula , from "Math Panels" then click "Miscellaneous" then click "textdegree".

1

The \autoref command tries to detect the underlying counter for the reference, this is lstlisting in this case and looks for a corresponding \lstlistingautorefname, which is not defined so far. This has to be provided then. The unfortunate feature for this that each lstlisting environment still has the same counter. And other non-algorithm environments ...

1

Why do you specify the float option if you don’t want the listing to float at all? You can have a caption option and a label option (beware: not \label) even without creating a floating object. Try this: \documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage[italian]{babel} \usepackage{color} % or xcolor \usepackage{listings} ...

4

Apparently, listing options is evaluated before before=\getnumlen{#1} is used and numlen set. This means that numlen is 0pt --> the \getnumlen{#1} must be called in this special option block (too). A dirty trial --> Use \getnumlen{#1} in basicstyle option --> it's an effective code macro and no typesetting/font macro, so it should not harm there. ...

0

Finally, here's what worked for me: \lstset{language=sh, frameround=fttt, basicstyle=\ttfamily\footnotesize, stringstyle=\itshape, commentstyle=\ttfamily, identifierstyle=, % nothing happens inputencoding=utf8x, extendedchars=\true, showstringspaces=false, showspaces=false, showtabs=false, particular underscores frame=single, fontadjust=true, ...

10

My very first attempt is something like morekeywords={>, etc}. But every > at the end of comments is colored pink. I cannot override its color by, say, moewkeywords=[9]{-->}. Then I found that it is probably because < and > are special in this case. More precisely, Listings actually takes care of tags by the following: when you say ...

1

Here a solution from this answer \documentclass{beamer} \usetheme{Madrid} \usecolortheme{whale} \usepackage{listings} \setbeamertemplate{navigationsymbols}{} \newsavebox{\mysavebox} \begin{document} \begin{lrbox}{\mysavebox} \begin{lstlisting}[language=SQL,mathescape, showstringspaces=false] SELECT ENAME FROM PROJ, ASG, EMP \end{lstlisting} ...

2

I assume the problem arises because of \usepackage[utf8]{inputenc}. Unicode characters are only supported, when there is a font encoding, which contains the character. Otherwise package inputenc would not know, how to print the character. The encoding TS1 can be used, which is loaded by package textcomp. The next obstacle is that ackage listings does not ...

1

Do you mean ${^\circ}$? This would give you the degree sign, when option mathescape is enabled. And your script would look like this: \documentclass{article} \usepackage{listings} \begin{lstlisting}[mathescape] 10${^\circ}$C \end{lstlisting}

Top 50 recent answers are included