# Tag Info

## New answers tagged listings

3


1

This adds an extra brace group to make the box setting in \lst@DeInit "color safe" then removes \normalcolor as egreg mentioned in comments. Seems to work on this example.. \documentclass[a4paper]{book} \usepackage[T1]{fontenc} \usepackage{color} \usepackage[ hang, small, it, hypcap=true ]{caption} \usepackage{fancyvrb} \usepackage{listings} ...

2

If you are willing to create the verbatim component in advance of the listing, this can be done... If you need more than one verbatim block per listing, the myverbbox environment allows you to give names to the verb-boxes (rather than the default \theverbbox as shown here). \documentclass{article} \usepackage{listings}% http://ctan.org/pkg/listings ...

5

Yes, I would recommend you use \lstinline so that the same style is applied: Note that even though it appears the formatting is the same, if you look carefully you will notice that the spacing of the keywords in the \lstinline is slightly different than the listings. The reason for that is that the default for \lstinline as per the documentation is that ...

5

You can do something like the following, what you need is the internallinenumbers macro: \documentclass{article} \usepackage{tcolorbox} \usepackage{lineno} \begin{document} \begin{tcolorbox}[middle=0mm,boxsep=0mm] \setlength\linenumbersep{1cm} %sets the distance of the line numbers from the margin \begin{internallinenumbers} \begin{itemize} ...

3

\documentclass{IEEEtran} \usepackage{listings,multicol} % <--- multicol only required, if the multicols= option shall be used \usepackage{filecontents} % <--- only needed to provide example code \usepackage{lipsum} % <--- only needed to provide dummy text \lstset{language=Java, basicstyle=\ttfamily\footnotesize} ...

1

Until now I didn't find a way to make a listing span two colums using the command that reads the code from a file (\lstinputlisting). However, I managed how to do it by putting the code in the latex document, as follows: \begin{lstlisting}[float=*] code goes here \end{lstlisting}

4

If you must do this, it is possible with tikzmark. But watch out that you choose an appropriate escape character, which is never used in the listing itself. I would not recommend it though. It requires manual edits to your listing source, which may or may not be feasible, depending on the length of the listing. There are also better, clearer ways to explain ...

1

This is an attempt, but I am not sure what the OP really requires. \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{listings} \begin{document} \begin{tcblisting}{listing only,arc=0mm,auto outer arc} \documentclass[<options>]{<documentclassname>} \begin{document} \tableofcontents \chapter{section} \end{document} \end{tcblisting} ...

0

$\texttt{\textbackslash}\overbrace{\texttt{documentclass[<options>]}}^{\textrm{above text}}\underbrace{\texttt{\{<options<\}}}_{\textrm{below text}}$ Next time post a better quality image, please. EDIT: after your edit, I think you can't mix math mode and listing environments... Mine is a workaround.

0

To typeset code in a document, use the listings package. To have sections in appendices, just use \section as you normally would; they will automatically be numbered as A.1 etc.

3

We now have an Environment (with xparse, but not necessary) that lets everything we need to look like article. Hardest part were the equation nubers because of the lacking beamer font template. You haveto use ~ for the white space in the beamer template names. \makeatletter \NewDocumentEnvironment {EmulateArticle} {} { %Roman Font: \rmfamily ...

20

You can adjust the in and out angles as well as shift the location of the start and end points: Notes: I also added basicstyle=\ttfamily to have a more listings like output. A \tikzmark was added on the left and right of each mark to simplify the computations of the midpoints. Code: \documentclass[11pt]{article} \usepackage{listingsutf8} ...

4

The problem is the \underbar command in your moredelim setting: With unicode-math it is a math command. You could use e.g. the ulem package and \uline instead: \usepackage{ulem} ... moredelim=[is][\uline]{_}{_},

3

As far as I know, tabu doesn't support listings even in the tabu* environment. However, I found that pythontex works: \documentclass[11pt]{article} % use larger type; default would be 10pt \usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX) %%% PAGE DIMENSIONS \usepackage{geometry} % to change the page dimensions \geometry{a4paper} ...

3

Use caption={[Short caption]Very long and frustrating caption that noone want to see before this page} Full code: \documentclass[11pt,a4paper]{article} \usepackage{listings} \usepackage{color} \usepackage{courier} \definecolor{dkgreen}{rgb}{0,0.6,0} \definecolor{gray}{rgb}{0.5,0.5,0.5} \definecolor{mauve}{rgb}{0.58,0,0.82} ...

0

To clarify more, the issue was: the generated list of listings is included in the ToC as Contents instead of List of Listings. The solution is: as a first step is adding \renewcommand\lstlistlistingname{List of Listings} in the preamble to change the name from being Contents to List of Listings, inside the document (after \begin{document}) just include ...

2

A bit of hacking is required; see below. \documentclass{article} % the following two packages are for bold typewriter font \usepackage[T1]{fontenc} \usepackage{beramono} \usepackage{listings} \usepackage{xcolor} \lstdefinelanguage{iCli}{ comment = [l]{\%}, literate = \#{{\processhash}}1, %<-- required for bold prompt ...

3

While listings provides the key-value numberfirstline (set to false by default), it doesn't seem to deliver on the promise of not numbering the first line. As such, the following is work-around: Start "numbering" from 0 and check when printing the number whether it should be printed or not using a conditional. \documentclass{article} \usepackage{listings} ...

2

Add firstline=2 in the \lstset. \lstset{language=Java, firstline=2, numberstyle=\scriptsize, numbers=left, numbersep=5pt, numberblanklines=false, captionpos=b, basicstyle=\small\sffamily, columns=fullflexible, xleftmargin=16pt, frame=leftline, breaklines=true, tabsize=2, ...

Top 50 recent answers are included