# Tag Info

## New answers tagged listings

6

Something like this? The style is 'very' special, in my point of view! \documentclass[oneside]{report} \usepackage{fontspec} \setmonofont{Bitstream Vera Sans Mono}[Scale=MatchLowercase] \usepackage[margin=2.5cm]{geometry} \usepackage{listings} \usepackage{tcolorbox} \tcbuselibrary{breakable} \tcbuselibrary{skins} \tcbuselibrary{listings} ...

0

Basis Ideas The idea here is very simple. Simply define two styles, one with no line number, another with line numbers. Then input the first line of listing with the first style, input the rest with the second style. The first attempt produced a small hitch where the physical second line was being numbered 1. A patch from ...

0

This does not affect just the amsmath environments. This minimal example also exhibits the problem: \documentclass[12pt,a4paper]{article} \usepackage{listings} \lstset{mathescape,keepspaces} \newcommand\identity[1]{#1} \begin{document} \lstinline!let $v_1$ = 10 in $v_1$ + $v_2$! \identity{\lstinline!let $v_1$ = 10 in $v_1$ + $v_2$!} \end{document} ...

1

I'd consider defining your own floating environment with the float package, doing something like this: \usepackage{float} \usepackage{listings} \newfloat{lstfloat}{htbp}{lop} \floatname{lstfloat}{Listing} Now, you can create a floating listing with the following syntax: \begin{lstfloat} \begin{lstlisting} % code here \end{lstlisting} \end{float} This ...

0

Instead of using listings, you could try to use the package minted, that relies on the external program pygmentize (http://pygments.org/). As the homepage states: support for new languages and formats are added easily; most languages use a simple regex-based lexing mechanism

21

The tcolorbox package can nicely display literal LaTeX code and its output when being called in a very configurable manner, depending on the argument of the tcblisting environment. This environment displays by default LaTeX code literally but the coding/scripting etc. language can be changed to anything known to the underlying listings package too. (or ...

2

One possibility is to approximate it using math mode. That character looks a lot like $^{\mathsf{L}}$, so it's possible to just use that in the literate option: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstset{ basicstyle=\large\ttfamily, breaklines=true, breakatwhitespace=true, literate=% ...

0

I suppose that there is no typewriterfont for thai. You can try the Code2000 font, which is, of course, not a typewritzer font, but has all characters: \documentclass[12pt,a4paper,oneside]{book} \usepackage{fontspec} \setmainfont[Scale=1.4]{TH SarabunPSK} % Thai Font \setmonofont[Scale=MatchLowercase]{Code2000} \XeTeXlinebreaklocale "th_TH" ...

1

The commands \Suppressnumber on \Reactivatenumber from the answer you mentioned can be used and no change is needed. You just have to call \Suppressnumber before the \begin{lstlisting}. Example: \Suppressnumber \begin{lstlisting} First line.|\Reactivatenumber| % NO ON THIS LINE! Second line. % START WITH LINE NUMBER 1 HERE Third line. Next ...

0

This is a very common problem, and is related to the way listings processes its input. When you escape within a listing, no listing-related processing occurs, so you'll find that not only the formatting changes, but also the natural spacing. Moreover, you'll notice a difference between the spacing supplied via lstlisting and the inline lstinline. Either way, ...

2

Correct the last line in your \lstset definition like this: {.3}{{\color{codeblue}.3}}{1} But the spacing then will be not consistent, so, I suggest another workaround: {.}{{\color{codeblue}.}}{1} Now this will produce:

1

This is a common problem, stemming from the fact that you can't have verbatim content as part of a macro argument. In your case, the verbatim content is a listing, and the macro is \ifbool{<bool>}{<true>}{<false>}. However, etoolbox's \newbool{<bool>} creates a primitive TeX \if<bool>, which you can use to condition. So, ...

2

You should call literate with an asterisk, like this: literate=* {0}{{{\color{codelightblue}0}}}1 {1}{{{\color{codelightblue}1}}}1 {2}{{{\color{codelightblue}2}}}1 % and so on This tells listings that literate should not override other syntax highlighting, including strings and comments. When I made that change, this is the output I got: ...

1

Answering my own question: I found the cause of the lines on the bottom and the top of the code. Its frame=tb. This should be changed to frame=none.

1

Follow Insert > Program Listing to insert a listing. Then right-click inside the listing and choose Settings... > Float (under Main Settings / Placement).

7

It turns out that I am not able to sleep. As promised, here is a version using tcolorbox and listings. \documentclass[a4paper,11pt]{article} \usepackage[top=19mm, left=12.925mm, right=12.925mm, bottom=19mm]{geometry} \usepackage{xcolor} \usepackage{listings} \usepackage{xcolor-solarized} \lstdefinestyle{mystyle}{ basicstyle = ...

1

With help of two new packages: makecell for column headers and multi row cells and paralist for compact lists. Package mathtools (the same result can be obtained by use of amsmath package) serve only for \text{...} command in one column header. Probably it will somewhere else in report. With this I made the following table: with code: ...

1

Look up a suitable symbol http://mirrors.ctan.org/info/symbols/comprehensive/symbols-a4.pdf and then use it: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings,amssymb} \lstset{literate ={⮀}{$\leftrightarrows$}1} \begin{document} \begin{lstlisting} a listing with ⮀ symbol \end{lstlisting}

1

Yes it's possible, as long as the font you're using has the character. \documentclass{article} \usepackage{fontspec} \setmainfont{Symbola} \begin{document} \char"2B80 \end{document}

0

Add the following package \usepackage{listingsutf8} Or provide an MWE that the community can try to solve your problem.

Top 50 recent answers are included