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

learn more… | top users | synonyms

2
votes
1answer
46 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") ...
1
vote
1answer
527 views

TeXstudio not correctly working on Mac OS X

Yesterday I installed TeXstudio on my Ubuntu system. I realized it has nice functions like "jump to PDF" (goes to PDF and highlights the marked text) and "go to source code" (goes to the source code ...
8
votes
3answers
327 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.
5
votes
1answer
5k 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 ...
4
votes
1answer
95 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
39 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 ...
52
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 ...
5
votes
3answers
116 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 ...
6
votes
1answer
283 views

How can I get proper Matlab syntax when typesetting Matlab source code using the algorithm package?

I'm currently using the algorithm package for typesetting Matlab source code in my document. However, the way keywords are typeset doesn't match the Matlab syntax. For instance, \EndFor is typeset as ...
7
votes
1answer
121 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 ...
3
votes
1answer
85 views

Formatting the thread call stack

Given a thread call stack as follows: FATAL org.apache.hadoop.mapred.TaskTracker: Error running child : java.lang.OutOfMemoryError: Java heap space ...
4
votes
1answer
84 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
55 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
83 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' --------------------------------- ...
10
votes
3answers
297 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
152 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 ...
9
votes
2answers
138 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 ...
3
votes
4answers
206 views

Formatting the SQL-like script

Suppose we have a script as follows: a = LOAD 'data' USING BinStorage AS (user); b = GROUP a BY user; c = FOREACH b GENERATE COUNT(a) AS cnt; d = ORDER c BY cnt; How to write the latex code to ...
6
votes
2answers
283 views

How to put source code in a LaTeX table?

I am comparing source in a paper and I would like to put them in a table, so the differences are easily spotted. I used the following LaTeX code: \begin{tabular}{ | l | l | l |} Option 1 & ...
2
votes
0answers
37 views

Format Inline source code like Stack Exchange [duplicate]

Stack Exchange formats code nicely with backticks using Markdown. Example: int foo = bar++ I've seen other posts that recommend using listings, specifically \lstinline to do inline source code. ...
1
vote
0answers
207 views

Make arrows inside lstlisting

Inside my lstlisting environment I want to make the assignment symbol an arrow instead of =. How can I do that? Adding just \leftarrow doesn't work, because then the whole word is displayed.
5
votes
1answer
88 views

Is there a tool for cleaning BibTeX source from LaTeX style escapes?

I have a BibTeX file which uses the old style LaTeX escapes, for example author = {Fjeld, Morten and Sch\"{a}r, Sissel Guttormsen} I want to read the file with a Scala script using jbibtex and ...
24
votes
2answers
825 views

How to understand and write LaTeX code?

LaTeX is like a language. In order to write LaTeX code I have to understand the "word" and the "sentences structure". I have searched on wiki, some LaTeX books, but they just give the LaTeX command, ...
20
votes
6answers
903 views

Why doesn't LaTeX interpret `(` as `\left(` and `)` as `\right)`?

First of all I love LaTeX/MathJax; I use it a lot, but there are couple of things I hate about it. Sometimes the code becomes so messy that I almost can't read it without looking at the output, while ...
4
votes
1answer
96 views

TeX-aware source line wrapping

For various reasons, I prefer to have short physical lines in my latex documents, so that the various editors I switch among don't need to soft-wrap the display. But many GUI editors have terrible ...
6
votes
1answer
151 views

Where to find LaTeX commands source code?

I would like to know where can I find the definition of an original command. That is, let's say I want to redefine the command \ref so when I type it, instead of showing just the number of the label ...
7
votes
1answer
122 views

Could significant speedups be gained from package code minification?

Wikipedia: Minification is (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code ...
3
votes
0answers
87 views

Where can I share useful but unpolished code / hacks?

During the course of writing my thesis I've come up with loads of useful macros and hacks and implemented them for my own use. For a few of them I've actually written and published packages. But ...
9
votes
2answers
3k views

What's the best way to typeset C++ codes in latex?

I'm participating in a programming contest and we are allowed to prepare a team reference document which must not exceed 25 pages. Typically we will prepare many code templates and this year I'm ...
2
votes
1answer
132 views

Adding caption and counter to source code environment

I have a source code listing with minted environment. How can I make a counter/caption to be shown as follows. I also need to make \tableofsourcecode to enlist all the source code references. The ...
6
votes
1answer
213 views

Including LaTeX documentation as comments in source code

I am working on a large C# project (hundreds of source files). I am trying to add documentation on various user inputs and options. For maintainability I would ideally like to be able to write the ...
2
votes
1answer
130 views

Handle % character in verbatim inside a grey box

I found this snippet on the internet which is used to produce a text area inside a greybox. \newcommand\greybox[1]{% \vskip\baselineskip% \par\noindent\colorbox{lightgray}{% ...
6
votes
2answers
154 views

Should I use a space or a new line after a period?

After a period in a .tex file, within a paragraph, should I use a space or a new line? I.e. like this: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus vestibulum metus ut ...
5
votes
2answers
722 views

Folding entire section in AUCTeX?

I'm new to AUCTeX and I wonder: is it possible to fold entire sections or subsections of a LaTeX document for a better overview, so that they are only represented by their headline (kind of a tree ...
0
votes
0answers
48 views

Math-mode aware search/replace utility? [duplicate]

As I gradually update the source code of my LaTeX documents to conform to new conventions, I find myself in need of a search/replace utility that is (or can be made) aware of LaTeX math mode. Often I ...
6
votes
1answer
499 views

Enforce a line-break inside \lstinline

I use \lstinline{foo} from the listings package to set pieces of code in regular text. To get automatic line-breaks I use the following options: \lstset{ breaklines=true, breakatwhitespace=true, ...
10
votes
1answer
1k views

What are the standard styles to format LaTeX source code?

In any other programming languages, we have several ways to format our source code. For example, some of the standard styles are: Allman(ANSI) K&R GNU .... Within LaTeX, I couldn't find a neat ...
15
votes
2answers
2k views

Colored background in inline listings

I would like to make inline code more distinguishable from the text surrounding it, and I thought that using a background might work (like it is done on the stackexchange pages.) Since I use the ...
8
votes
1answer
142 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 ...
14
votes
1answer
622 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 ...
19
votes
1answer
967 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} ...
3
votes
1answer
2k views

lstlisting line wrapping

How is it possible to let lstlisting wrap lines? I've troubles with following block: \begin{lstlisting}[language=java] public class MeasureStationControllerV0Test { MeasureStationControllerV0 ...
4
votes
2answers
700 views

Beautifully format text of an external document

I have some formatted long text files looking like this: f=50 k_max=420 Iteration Func-count min f(x) Procedure 0 1 7.07212e-09 1 2 ...
118
votes
4answers
5k views

What is the use of percent signs (%) at the end of lines?

I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
2
votes
1answer
209 views

Removing keywords and subject descriptors from a ACM template

I'm trying to customize a ACM template, the Large Format Single Column one [1] and really the main thing I want to get rid of is the subject descriptors and keywords part. I realize how important they ...
6
votes
1answer
365 views

Is there an alternative to LaTeX which isn't whitespace sensitive?

I have been using LaTeX for about a year now, and I quite like it. However, I like to space out my source code. In most languages, this doesn't cause an issue, as extra newlines don't affect meaning. ...
3
votes
2answers
174 views

Overbrace in lstlisting of Scala code

I want to add an overbrace to some text in a Scala code listing (using lstlisting). \begin{lstlisting} object TypeClass extends FooParMain { def newApp(args: Array[String]) = new FooParApp { ...
3
votes
0answers
170 views

Regular expressions in listings [closed]

I'm looking for a possibility to use regular expression in listings. I'd like to highlight each N thats followed by 4 decimal numbers for example N1234. How can I achieve that? Here is an example: ...
4
votes
1answer
152 views

Embed distributed LaTeX file/code to the PDF?

I have read of the possibility to embed the LaTeX source in a generated PDF, see the question here. Do you know of a way to do this with distributed TeX file, i.e. for a TeX file which is stored in ...
7
votes
3answers
229 views

Expanding a minted command inside a macro

I am currently trying to speed up the compile time of a document that uses minted. I would like to be able to have certain language features (and style) appear the same in both a minted environment ...