{sourcecode} is a collection of computer instructions, here for (La)TeX.

learn more… | top users | synonyms

2
votes
1answer
15 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
28 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
39 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 ...
2
votes
0answers
27 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
97 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
23 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
21 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
46 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} ...
1
vote
0answers
37 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
61 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
45 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
129 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 ...
12
votes
4answers
679 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
140 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 ...
2
votes
1answer
281 views

What is the best way to include R code in the Latex paragraph

I am a newbie in Latex. I have two simple questions regarding including R code in Latex. Q1: For a block of R code, I use 'listings' package, as follows. \documentclass[12pt]{report} ...
2
votes
1answer
53 views

Bold code in listings environment

I want to do a box like this but the bold text doesn't appear. Edited: \documentclass{article} \usepackage{listings,xcolor,etoolbox,lmodern} \definecolor{verbgray}{gray}{0.9} ...
4
votes
1answer
50 views

Put default text in listings environment

I want to make a gray box with some code inside but it should already appear a centered tilde followed by a dollar sign. Or how can I use a command inside the environment to obtain certain text like ...
2
votes
1answer
90 views

How can I add source code like the following image in the beamer frame?

I have tried the listings package, but the question is that I can not type math equation in it. (The line number on the left start from the first line, i.e. type val is also OK for me.)
3
votes
0answers
69 views

Listing sourcecode - two columns, associations with colored background

I stumbeled over a way of formatting sourcecode in a book I am currently reading. It looks like this: So basically we have a following structure: There are two columns. Left column contains the ...
4
votes
1answer
84 views

LESS and SASS source code formatting

I need to add piece of source code in LESS and SASS. Piece of code is divided into two columns. First column is source code in Less and second column in Sass, something like on this page, but without ...
1
vote
1answer
121 views

How do I highlight a block of source code in LaTeX?

I have many blocks of source code in my document (each of them is at least 40 lines). I would like to format parts of these code blocks, preferably with some annotations on the right. I was thinking ...
3
votes
3answers
99 views

How to insert the inbuilt keywords in latex

I am creating a simple tutorial file to take a seminar. My problem is: I want to get the output as "\textbf is used for making the font bold". How can I get that? Likewise, i want to make this for ...
0
votes
1answer
117 views

LaTeX query about using LaTeX

Is it posible to "nest" the LaTeX source code to a text edit program, so it would be easier for users to use it. I would like to ask you how could I get the LaTeX source code?
4
votes
2answers
196 views

Adding a Caption to \lstnewenvironment using \mdframed

I found on the Internet the piece of LaTeX code I really liked : \documentclass{article} \usepackage{listings,mdframed,xcolor} \definecolor{codeBackground}{rgb}{0.9, 0.9, 0.8} ...
5
votes
1answer
384 views

Embedding images in tex file as base64 strings?

A commonly asked question on this site is how to embed images directly in a .tex source file, without the need for the image to exist in a separate file. Examples of such questions (often marked as ...
5
votes
2answers
834 views

Where do I find the source code of beamer in a MiKTeX installation?

I'm looking for the source code of default beamer themes (*.sty) for studying purpose. A file content search for keywords like \setbeamertemplate only returns texworks.exe. If these definitions are ...
2
votes
0answers
40 views

Cyrillic in minted label

Is it posible to use the Cyrillic text for the label option in minted source code listing? I try to compile this piece of latex code with xelatex: ...
3
votes
0answers
113 views

What font do you use for writing latex code? [closed]

While mono-spaced fonts are generally accepted as the best option for programming and coding, I feel they make it to hard to read longer texts and thus are not my preferred font for writing latex. ...
13
votes
1answer
231 views

Possible to have # start a comment that ends at EOL or at next #, whichever comes first?

I'm trying to create a listings language in which the # symbol starts a comment that ends at the end of the line or at the next # symbol encountered, whichever comes first. Of course, I'd like to ...
4
votes
1answer
54 views

Getting the line number in the source code for an equation?

I have a long file (about 5000 lines, the pdf is about 100 pages) and I want to find an equation with a specific number (for example: 11.5) in the source code. Of course, I have access to all the ...
14
votes
1answer
289 views

How does minted work from a point of LaTeX-User?

The package minted is one of the most famous package for highlighting source code. But how does it work?
3
votes
0answers
38 views

Code in listing not formatted correctly [duplicate]

My preamble is as follows: \documentclass{llncs} \usepackage{xcolor} \usepackage{harvard} \usepackage{listings} \usepackage{chngcntr} \makeatletter \lst@InstallKeywords ...
8
votes
2answers
237 views

safe places to skip lines in the source

Ideally, I would like to be able to skip lines before and after \section, before and after many environments (theorem, itemize, enumerate, etc.), between \items in a list, before and after ...
4
votes
1answer
160 views

How to include a programming language source code file in a plain TeX document?

I have some Java and C source codes and I want to include them in my .tex document. I can't simply copy and paste them into my document: In fact, doing this way, the code won't appear with the right ...
3
votes
2answers
443 views

Typeset source code with tcolorbox

I want to typeset source code with tcolorbox package. How is possible in this package not to create static boxes but rather boxes that adjust according to the width of the code I write both vertically ...
2
votes
1answer
81 views

Including sample output as whole pages

What would be the best way to include sample LaTeX output, in the form of (reduced) whole pages, into another document that discusses its typesetting? I am thinking of creating one ("example") ...
9
votes
3answers
7k views

Writing source code in LaTeX as text

Is there a package that allows source code in LaTeX as text? I rather not use listings package because the code takes too much space. Copy/paste is tedious because the spaces are not preserved.
4
votes
1answer
152 views

lstlistings works strangely

I have some Java source code and want to display it in LaTex: \lstset{language=Java} \begin{lstlisting} IntentFileter intentfilter = new IntentFilter(); ...
0
votes
0answers
46 views

Redirecting *.aux, *.log files, with a command in the tex file [duplicate]

Is there a latex command that can be included in a file compiled with pdflatex that can direct the *.aux, *.log files resulting from the compilation process, to a specific folder ? I have seen ...
0
votes
1answer
288 views

How to recover lost .tex files [closed]

Initial position I recently bought a new computer, and I thought I have backed up all of my LaTeX files and documents from my old computer onto an external hard drive. Upon searching for old LaTeX ...
5
votes
3answers
200 views

When to break lines? [duplicate]

I am very new to LaTeX. A newline in the input file does not mean anything to LaTeX. An empty line in the input file means a new paragraph. Trouble is, when I view my sources with different text ...
56
votes
4answers
3k 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
226 views

Display of source code in customised (IDE-like) format in PDFLaTeX

I want to put some “C” source code snippets in latex (I am using PDFLaTeX), but I don’t get the result that I want using the “listings” package. What ideally would like to get is the same result as ...
4
votes
1answer
182 views

How can I reference line numbers in an external source file (e.g. C++) in a maintainable way?

I doubt there's a very efficient way to do this, but LaTeX seems to be capable of just about anything. I'm writing up a document to explain a piece of C++ source code to future users of the package. ...
2
votes
1answer
232 views

Add coloring rules for specified language keywords in lstinputlisting [duplicate]

I would like to add coloring definition for e.g. @Override in java files. How can I do that ? So far I have the following coloring definitions : \documentclass[a4paper,11pt]{article} ...
2
votes
1answer
164 views

Displaying Examples Side By Side [duplicate]

I am currently learning LaTeX from 'The Not So Short Introduction To LaTeX' and in that book many examples are displayed side by side: $a^2$ 'Left side of page' --------------------------------- ...
12
votes
3answers
659 views

Empty line (in code) before enumerate environment

I like my code to look like this: \documentclass{article} \begin{document} \begin{enumerate} \item test text \begin{enumerate} \item 1 \item 2 \item 3 \item 4 \item 5 ...
5
votes
1answer
456 views

Code highlighting for imported source files

I have several source code files that I would like to include in my document. I know that I can use verbatiminput to get the lines from the file, and use lstlisting to highlight the code, but I ...
12
votes
2answers
225 views

Can spaces at the beginning of a line ever cause problems?

To structure my sourcecode, I often use spaces for padding: \newcommand{\st}[1]{% \begin{tabular}{lr} \emph{Student} & \emph{Score}\\ #1 \end{tabular}% } Can this ever cause ...