{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

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 ...
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
32 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
22 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
102 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
30 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
40 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
55 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 ...
4
votes
1answer
104 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
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, ...
12
votes
2answers
14k views

TeXStudio doesn't recognize some commands

I'm starting to use TeXStudio. I'm having some issues, for example with \begin{align*} \sqrt[n]{a}^2-\sqrt[n]{ab}&=m\sqrt[n]{a}\\ \end{align*} When i put the point on align* i get a small ...
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 ...
62
votes
12answers
4k views

What are the pros and cons of using hard wrapping, and why is it so common with LaTeX?

It seems that hard-wrapping - i.e. inserting a newline when the line reaches a certain threshold - is extremely common in the LaTeX source when writing technical papers, either by manually inserting ...
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
65 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
45 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 ...
58
votes
4answers
4k views

Defining custom commands is bad style?

I recently received this in a e-mail from my professor Good LaTeX style would preclude creating any of your own commands, counters, etc. (Most journals would reject submissions with user-defined ...
7
votes
1answer
143 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
74 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
83 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, ...
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 ...
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. ...
0
votes
1answer
41 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 ...
12
votes
2answers
394 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 ...
45
votes
2answers
5k views

Styleguide for LaTeX similar to the Google styleguides?

Even though I don't work at Google, the Google Styleguides have been very helpful for me in adopting consistent, readable style conventions for my code. Unfortunately, there is no Google Styleguide ...
3
votes
0answers
68 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 ...
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
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
48 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 ...
15
votes
2answers
2k views

Is there such a thing as a LaTeX code formatter

I was looking for this a while back for JavaScript, but I was wondering a general purpose one exists for all, or most languages. For example for LaTeX I would put the following in a text box $f_i^k+...
22
votes
2answers
2k views

Pretty printing of LaTeX code

In many MWE here on TeX.SE the LaTeX code is written without explanatory comments and as compact as possible. An Example: \documentclass[ngerman,fontsize=12pt,pagesize]{scrreprt} \usepackage{lmodern}...
23
votes
4answers
7k views

Why can't TeX Live's size be reduced?

I understand that the following question has been answered Why is the MacTeX distribution so large? Is there anything smaller for OS X? but my question differs from it. I just installed MacTeX and ...
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
47 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, ...
4
votes
2answers
594 views

Is there a way to make ChkTeX ignore TikZ code

ChkTeX does not like TikZ, and will report a bunch of errors. Is there a way to make ChkTex ignore TikZ code?
2
votes
3answers
92 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 ...
1
vote
0answers
125 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
123 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
85 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
286 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
273 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 ...
7
votes
2answers
6k views

Is there a good definition for highlighting PHP code in listings?

Does someone have a good definition for highlighting PHP code with the listings package?
10
votes
2answers
239 views

Where can I find a manual for learning the fundamental background of LaTeX source?

I would like to know if there is some manual from which I can learn the bases of LaTeX programming language. I need something universal, not related to some specific package or class, that at the end ...