{sourcecode} is for questions regarding the source code for (La)TeX documents, including syntax questions, style decisions, package sources, etc. For questions about printing code in LaTeX documents, use the {code} tag.

learn more… | top users | synonyms

-1
votes
0answers
33 views

Built-in LaTeX instruction to modify the file where it is written

Using the \input command I can add LaTeX code from other files to my main file at typesetting. Is there a command similar to \input but with the difference that it would actually replace the call ...
0
votes
0answers
18 views

Getting package error when importing source file

I have a problem with import source code into my tex document. The source code is in language C with lots of comments like "\" and "* *\".
2
votes
1answer
34 views

\lstdefinelanguage cannot handle keywords #if, #endif,

I need to insert C-code snippets in my LaTeX document. Therefore I define a C-code language syntax highlighting: \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{color} \definecolor{...
1
vote
1answer
26 views

Line break character in equation code

Equations are sometimes part of the text, for example in \documentclass{article} \begin{document} The Pythagorean theorem is often stated as the equation \[ a^2 + b^2 = c^2 . \...
1
vote
1answer
51 views

Good settings for typesetting source code with wide lines?

I'd like to typeset some source code with minted. Unfortunately, a lot this source code runs over 80 columns, some of it up to 132. What are good settings (and open source fonts?) to use with minted ...
5
votes
4answers
103 views

Does the tab key do anything?

As far as I can see, the tab key doesn't do anything and can therefore be used safely without altering the output. I googled it but I haven't found anything. It's usually all about the tab command.
3
votes
1answer
31 views

Changing the line number in code listing

Below is how the code listing looks like now: I want to change line number 8 to blank, and line number 9 to 10. Reason is that they are actually two lines at ... (at line 8), how should I do that? ...
2
votes
1answer
41 views

Cannot include courier into latex beamer listings

I have the following set up for my listings: \documentclass[russian,pdf]{beamer} \mode<presentation>{} \usepackage[T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian]{babel} \...
1
vote
0answers
56 views

any Tex template for this arxiv article?

I am from optimization and control society. I would like upload a paper in a non-description way, probably, like. http://arxiv.org/pdf/1604.00527.pdf Could you please help figure out how the format ...
0
votes
0answers
38 views

matlab-prettifier with fancyvrb-style of label / frame

I wonder how to make the frame line around caption of listing not being printed (top line being broken into two by caption in the middle) when matlab-prettifier (or listings package) are being used, ...
4
votes
1answer
112 views

How to upload my moduled tex files in arXiv?

My first ever paper was accepted and I want to upload it to arXiv. However it seems a bit difficult, since it doesn't allow you to upload the .pdf right away..I uploaded my main .tex file but when on ...
0
votes
0answers
45 views

Russian encoding in tex-file

My fellow sent me an text-file with russian text. But when I opened it in TexStudio, all russian turned into this interesting squares. Both of us have similar encoding in TexStudio. How can I recover ...
1
vote
1answer
58 views

Length of external plain text file

(Xelatex) How can one determine the maximal line length (e.g. in characters) of a external, plain text file? This file likely contains special Latex characters. Usecase is syntax highlighted code by ...
4
votes
1answer
68 views

How to highlight (color/draw attention to) a particular snippet in Minted

I'm currently doing some work on error messages in programming languages. As such, I'm showing faulty pieces of code, alongside the compiler-errors accompanying them. I'm using minted for the code ...
1
vote
0answers
25 views

Recombining latex source code from multiple chapter files (not in compiled PDF)

I've written a manuscript using several chapter files and a main file. However, the journal I'm submitting to would like one continuous latex file for submission. I could copy and paste everything ...
3
votes
1answer
46 views

Elaborate C++ parsing and the listings package

I would like to have the colors the gruvbox coloring scheme for (g)vim uses in a lstlisting environment. Is the listings package too dumb to differentiate e.g. between "template", "const" and other ...
7
votes
1answer
144 views

! I can't find file `['

I am writing my thesis by using LaTeX and the toptesi package. I am mostly writing on my laptop, but sometimes I need to switch to my other PC. I encounter some problems here when generating the pdf ...
1
vote
0answers
16 views

Get source code as it is from output [duplicate]

I am trying to display my XQuery code in a latex document as follows: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \title{code} \date{January 2016} \begin{document} \...
1
vote
0answers
76 views

How can I define a new language? [closed]

i need to insert code into my document which is written in ST (structured text) (PLL language). Couldn't find any existing solution in the web. How to add the language to the package to use it? ...
0
votes
0answers
89 views

Displaying source code listing with strikethrough/strikeout

I'm preparing for a presentation in which I would like to show some source code with bits struck out. Does anyone know a package that can do that? I've googled but can't find anything. Here's my MWE, ...
0
votes
1answer
42 views

Unable to include “large” code in lyx files

Following this question I was able to insert (Java) code into my lyx document. However, when I try to visualize (export it as a .pdf) the following error comes up: I can't work with sizes bigger than ...
2
votes
2answers
97 views

Why does source code in my header of report appear?

In my header is source code where nothing is supposed to be. Main document: \documentclass[a4paper,12pt]{report} \usepackage{lipsum} \usepackage{fancyhdr} \usepackage{layout} \usepackage[headheight=...
2
votes
1answer
50 views

What is the correct way to refer to the code that one enters in an editor?

I am a question about terminology. When I think about source code I usually think about the code that a program is compiled from. But I also often call the code in the .tex file source code. Is this ...
3
votes
0answers
69 views

Diagrams of TeX Design

In order to understand TeX better, and in order to procrastinate on stuff that is almost certainly more important, I'm slowly working my way through a YouTube series of Knuth explaining TeX82 ...
1
vote
1answer
88 views

LaTeX graphical lines for domain results

As usual I have a problem with LaTeX code; this time is to show the results of domains interval for example when I have a rational function and I have to split domains into the Numerator one and the ...
2
votes
1answer
50 views

How to deal with large number of references in one \cite{}

I am writing a review type document and very often I have to cite 5+ papers in a single \cite{} command. I can't seem to find any documentation on how to best deal with this. The problem is ...
3
votes
1answer
131 views

Packages used in this image?

Does somebody know which packages were used to create the following homework assignment? I would like to insert Java source code in exactly the same way in my .tex files
0
votes
0answers
48 views

How to fix comment indentation of code using the listings package?

My problem is that the code itself is indented correctly, but the comments (e.g. //comment) are not. In my source file, I aligned comments in one column by using tabs. In the pdf produced by LaTeX, ...
12
votes
2answers
398 views

When is leading/opening whitespace of a line in a tex file important?

According to https://en.wikibooks.org/wiki/LaTeX/Basics#Spaces ... opening space is generally ignored. First of all, I don't know what generally refers to. I came across this using chktex a ...
2
votes
3answers
93 views

How can I add 1 line of source code (source code snippet) in a LaTeX document?

The easiest way of explaining this is probably to provide an example of what I want to do: Consider the following section of a LaTeX document. Calls to the function // a blank line ...
2
votes
0answers
45 views

Post a question based on another tex file - Eg. Legrand Orange Book template [closed]

If you modified the Legrand Orange Book template to include other environments, and are getting errors based on the new environment, how do you post your code? Thanks.
1
vote
0answers
126 views

JavaScript ES6 Code highlighting

I'm using the latest minted to highlight my sourcecode. I've got a lot of code listings using ES5 and ES6 javascript features but minted is lacking a lot of them still. What can I do to get proper ...
0
votes
0answers
22 views

Including a particular function from a source file

I know I can use the listings package to include specific lines of a source file in my document, but is there any option or package that would allow me to specify a particular function to include ...
9
votes
1answer
124 views

Finding METAFONT sources of a specific character

I'm trying to find out the METAFONT source of percent (%) character, which is created by \% with TeX. I am using the Normal CMR10 font. I am doing this, because I want a slightly modified version of ...
1
vote
1answer
49 views

How to prevent line breaks in code listings?

I am adding a big Linux terminal output as a listing and would like to prevent these line breaks from happening: e.g. user@pc ~ $ top PID USER PR NI VIRT RES SHR S %CPU %MEM ...
2
votes
1answer
86 views

Using `inputminted` in lyx has no effect on document

I'm trying to import a complete code file into a lyx document using the minted package. But the resulting document has no code at all. Here is a minimal example. And there's nothing in the resulting ...
1
vote
1answer
101 views

Using minted for syntax highlighting with RTL language reverses code

I'm writing a LyX document in Hebrew and I want to inset some inline code snippet but the code is reversed when rendered. The minimal lyx example is here. And it look like this: LyX source: #...
2
votes
0answers
287 views

Python console code with minted

I am using minted to highlight source code in my document. I have defined \definecolor{codeyellow}{RGB}{255,251,204} \newminted{python}{linenos,breaklines,frame=lines,bgcolor=codeyellow} in the ...
3
votes
1answer
137 views

Hanging indentation of source code within sentence a la Vim-LaTeX-Box

I've recently been playing with the LaTex-Box plugin for Vim and noticed the layout of the source code on their Github page: What interests me is the 2-space hanging indent within each sentence. ...
3
votes
1answer
274 views

How to insert sourcecode?

For my internship, I have to print all the source of my iOS application to a LaTeX file. Now I'd like to do this in a structured way by having sections, subsections and subsubsections for each nested ...
2
votes
0answers
25 views

Automatic reformatting / style checking of input files? [duplicate]

Coming from Python land, one of the best tools is autopep8 and alike which automatically tweak the layout and spacing of your programs to fit the PEP8 code style guide. My basic question is: are ...
2
votes
0answers
33 views

Indentation marker for listings

I'm currently writing a document that contains several code samples. I included them as lstlistings and played around with the colors and everything, so they loot quite nice now. My only problem is ...
1
vote
1answer
165 views

Python code block outside of margin

I want to include some Python code to my Latex document. I have read this Tex Stackexchange question and added the following code to get syntax highlights: \usepackage{color} \DeclareFixedFont{\ttb}{...
1
vote
0answers
38 views

Best practice for writing. Oneliner? Enter key? \\? \newline? [duplicate]

I just started using LaTeX to write my bachelor thesis and everything is already set up and working (took 2 weeks but it is finally done). I was just starting to write a chapter and am wondering what ...
0
votes
0answers
35 views

Is there an accepted best practice when it comes out to laying out code? [duplicate]

Many languages, such as python, have strict rules as to how best to lay out the code. I have looked around but I can't find anything that details this for Latex. For example when looking at creating ...
5
votes
1answer
68 views

How does the stripcommand in the pgfmanual file work?

I am trying to understand how commands are typeset for use in LaTeX documentation. To clarify, not using LaTeX to create documentation, rather to write documentation in LaTeX about using LaTeX (like ...
1
vote
2answers
73 views

Box and title of the box containing code [duplicate]

As the attached picture describe, this is what I am trying to replicate. Now the text does not need to be the same, since I am going to write different content inside but I really like the way this ...
5
votes
1answer
1k views

How to stop verbatim from converting tabs to spaces?

I am using verbatim to put some sample code in my document: \begin{verbatim} [start] printf{"Start command received"}; [stop] printf{"Stop command received"}; \end{verbatim} I ...
15
votes
5answers
2k views

List of books written in LaTeX with the source available

Is there a list of open source LaTeX books? I've only found these books but I want to know if there is a list with more diversity as this has only mathematical books. I want to find open source books ...
5
votes
1answer
200 views

question regarding tex design previously done by Yannis

i obtained a repository dump from github phd-master ( impressive work Yiannis has done i must acknowledge) i am in the process or rereading my draft of work for self publishing- and i have looked ...