Tag Info

New answers tagged

2

You need to put the vspace before the hspace and leave a blank line before the vspace, so it is working in vertical mode.


2

Within your aghdpl.cls class file, you'll see that chapters are set using a font size \LARGE (line 191-192): \titleformat{\chapter}[block] {\bfseries\LARGE}{\filright \LARGE\thechapter. }{0ex}{} However, ToC-related entries are set using only \Large (line 209): \renewcommand{\cfttoctitlefont}{\bfseries\Large} Since \lstlistoflistings is set just like ...


0

If you want only some lines to be discused in your paper you can easy split the listing in for example three parts, using option linerange={1-3} for the first 3 lines. If you want the real line numbers in your listing use for example option firstnumber=10 to start with line number 10. Here comes the MWE: \RequirePackage{filecontents} ...


5

For the usage of listings you have to use the fragile option for the frame: \documentclass{beamer} \usepackage{listings} \begin{document} \begin{frame}[fragile] \begin{lstlisting} Hello world \end{lstlisting} \end{frame} \end{document} Further information can be at found ...


4

The easiest thing to do here is to declare all digits as "letters" and define all your keywords with the keywords key alone, eschewing the otherkeywords key completely: \documentclass[12pt]{article} \usepackage{xcolor} \usepackage{listings} \renewcommand{\ttdefault}{pcr} \definecolor{Black}{gray}{0.0} \definecolor{Blue}{rgb}{0.12,0.29,0.53} \lstset{ ...


3

Better late than never :) As stated by Qrrbrbirlbel in his comment, the problem is that, because % is a (one-line) comment delimiter in the Octave language, listings treats your closing overlay delimiter @ as part of the comment. One workaround is to undefine % as a comment delimiter, but use literate to apply the comment style when that character is ...


2

Although not explicitly stated in the documentation I have found that the escaping only works in listings using the lstlisting environment, not within lstinline. See this: \documentclass{scrreprt} % Quellcode \usepackage{listings} % für Formatierung in Quelltexten \lstset{ escapeinside={(*@}{@*)}, % if you want to add LaTeX within your code } ...


2

I propose to put the the structure saving commands into the lower part only. Such, the numbering of the tcolorbox is not affected. To avoid the tocs and bookmarks problems, I suggest to deactivate \addtocontents and \addcontentsline as was done for \documentclass. My answer creates a new option protect structure which contains all this stuff. ...


2

The number within option in the definition of texexptitled has to be set to backupsection or \backupchapter (perhaps better) \documentclass[oneside]{book} \usepackage{listings} \usepackage{tcolorbox} \tcbuselibrary{listings}% \usepackage{xcolor} \usepackage[bookmarks=true, bookmarksopenlevel=2]{hyperref} %Definition of New Environments \tcbset{ ...


1

I'm not sure, if I understood your intention completely. But, I corrected the errors Christian Hupfer already mentioned, and I made a new macro \texexptitledinputlisting which hopefully helps for your own extensions. I kept the rest unchanged with small exceptions / corrections. \documentclass{article} \usepackage{xcolor} \usepackage{listings} ...


3

I would put the beamer example into a separate file which can be compiled for its own. Then, the source code and the beamer slides can be included into the target document. Here, I used example01.tex for the beamer file: % example01.tex \documentclass{beamer} \usepackage{blindtext} \begin{document} \begin{frame} \frametitle{First Frame} ...


3

This stores the current section counter and restores it after the listing environment. Internally, the section counter is reset for the listings output purposes. \documentclass{article} \usepackage{listings} \usepackage{tcolorbox} \tcbuselibrary{listings}% \usepackage{xcolor} \lstset{ % General setup for the package language={[LaTeX]TeX}, ...


5

As Jubobs commented while I was working on this answer, the problem is that ' is treated as a string delimiter in C, so everything until the next ' is considered part of a string. You can see this by setting stringstyle=\itshape or similar; everything following the ' is shown as a string. Discussion in the comments notwithstanding (I would recommend ...


7

The best way to show the output along with the LaTeX code is to use the showexpl package: Notes: To adjust the position of the output you can use the pos= option: top, bottom, right, left, outer, and inner. Code: %\RequirePackage{filecontents}% Comment out so that "example.tex" is not overwritten \begin{filecontents*}{example.tex} Here is some ...


7

The tcolorbox provides means for nice typesetting and direct output of listings LaTeX code. There are many conceptual and visual configuration possibilities, see the documentation of tcolorbox, e.g. in chapter 9 of the current version 3.12. However, a \begin{document}....\end{document} cannot be catched easily. Just relaxing \begin{document} etc. is no ...


1

You could add a rotated box with a (short) listing after the section title. My answer uses the tcolorbox package for the job. The given width of the box is the height of the rotated box. Obviously, the width/height has to be small enough to fit inside the page. This solution is not adequate, if you want to the listing to continue to the next page. Any ...


3

My answer uses the tcolorbox package for assistence with the boxing problem. Note that you should use the current version 3.12 (2014/07/29) of the package, i.e. you may have to update first. Version 1: The basic idea of the solution is to box the listing with a tcolorbox which is enlarged into the margins of the page. Here, I used a brutal enlargement ...


2

This should allow typing the characters you requested - basically adding more to the list of literates will allow other characters as well: \documentclass[a4paper,oneside]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{listings} \lstset{literate=% {Ç}{{\c{C}}}1 {ç}{{\c{c}}}1 {ı}{{\i}}1 {ö}{{\"{o}}}1 ...


0

Here is another solution: \documentclass[a4paper]{book} \usepackage[T1]{fontenc} \usepackage{caption} \usepackage{fancyvrb} \usepackage{listings} \begin{document} \begin{figure} \centering \lstset{xleftmargin=0.18\textwidth,xrightmargin=0.18\textwidth} \begin{lstlisting} trait Sys[S <: Sys[S]] { type Tx <: stm.Txn[S] type Var[A] <: ...


0

I use a similar solution to the one proposed by werner. However I prefer to define the minipage with text instead of line width: \begin{minipage}[c]{0.95\textwidth} \begin{lstlisting} \end{lstlisting} \end{minipage} "c" for centering and "0.95\textwidth" to make the listing a little bit smaller than the rest of the text.


1

There is a solution which works with the example files you provided at http://tex.stackexchange.com/a/65839/60451 The code \makeatletter \def\lst@lettertrue{\let\lst@ifletter\iffalse} \makeatother will make listings break lines at letter characters.


3

The problem comes from how the listings language for R is defined. If you look up the definition in lstdvrs.dtx (search for \lst@definelanguage{R}), you'll see that *, /, and _ are all defined as "otherkeywords": otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,_,/},% I refer you to this other answer of mine to understand why this is ...


4

A MWE is really needed here, so what follows is a bit of a shot in the dark... Edit: now you can specify a distinct style for numerical JSON values. \documentclass{article} %\usepackage[T1]{fontenc} %\usepackage[scaled=0.85]{beramono} \usepackage{xcolor} \usepackage{listings} \newcommand\JSONnumbervaluestyle{\color{blue}} ...


5

Use \lstset{breaklines} in your preamble (after loading the listings package); that should switch automatic line breaking on. Or use the matlab-prettifier package, which sets breaklines by default; see below for an example (I adapted the example paper for IEEE publications, which is available here). \documentclass[12pt,journal,compsoc]{IEEEtran} ...


4

Unfortunately, space characters cannot reliably be copied from a PDF. This answer on Superuser is bang on: The problem with PDF is that it doesn't really encode text. All it does is pretty much saying "Put those glyphs there, and those glyphs there". It's a format intended for print and high-fidelity document preview on screen but not so much to ...


5

Ok, after some thinking about how to do this with listings while avoiding manually specifying keywords, I suppose a syntax based solution may work. I.e. I defined a language for listings using moredelim and morestring to handle the most basic syntax of XML and get the following results: the corresponding code is: \documentclass{report} ...


5

Here, all code is shown: Here, some code is hidden: Here are some implementation details. Invoke the "ghosts" of Martin Scharrer and Donald Arseneau The \confidentiel macro defined below is based on a modified version of Martin Scharrer's \UL@putbox, which is itself a "phantom" version of a macro defined in Donald Arseneau's ulem package. Such a ...


1

Well, most of your questions have already been answered either in the question itself or in the comments, so here's just a recap to satisfy the site's mores: The workaround to allow spaces in keywords that microtype.dtx employs is to use the "non-breaking space" in lieu of a normal space to make listings believe that it's a letter, while it will be output ...


4

You seem to be asking several unrelated questions, here. On TeX.SX, we try to keep unrelated questions on separate pages. In the future, if you have multiple questions that are unrelated to one another, you should ask each in a separate TeX.SX "question". You'll stand a better chance of getting a satisfactory answer to each of your questions. Let me address ...


3

You were almost there. \documentclass{article} \usepackage{xcolor,listings,calc} \definecolor{lstgrey}{RGB}{217, 217, 217} \definecolor{lstback}{RGB}{246, 246, 246} \newlength{\numberlengthnormal} \setlength{\numberlengthnormal}{\widthof{\fontfamily{cmtt}\selectfont 999}} \lstnewenvironment{lstcpp}[1][] {\lstset{% language = C++, tabsize=2, ...


0

\documentclass{fiu} \makeatletter \def\TOC{\if@twocolumn\@restonecoltrue\onecolumn \else\@restonecolfalse\fi \chapter*{\contentsname \@mkboth{% \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% \@starttoc{toc}% \if@restonecol\twocolumn\fi} \makeatother \usepackage{listings} \begin{document} ...


1

The problem is a faulty hard-coded "TABLE OF CONTENTS" in the definition of \tableofcontents in the class; here's the original definition in fiu.cls: \renewcommand\tableofcontents{% \if@twocolumn \@restonecoltrue\onecolumn \else \@restonecolfalse \fi \begin{center} TABLE OF CONTENTS \\[1.5ex] CHAPTER \hfill{} PAGE ...


1

This is a workaround, by redefinition of \lstlistoflistings, place it into your preamble. The definition of \tableofcontents is awkward, in my point of view, but if that is the standard of the university ... so let it be ;-) \makeatletter \renewcommand\lstlistoflistings{% \if@twocolumn \@restonecoltrue\onecolumn \else \@restonecolfalse ...


6

As suspected you simply need to add the escapechar so that listings knows that you want to execute this code: Notes: The escapechar can be any character that does not appear in the listing, and indicates the start and end of the code that is to be executed. In the MWE below I used the $ charaacter. As the mcode package is not part of the standard ...



Top 50 recent answers are included