The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [sourcecode]

{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.

Filter by
Sorted by
Tagged with
3
votes
0answers
32 views

How to split long C/C++ code line on two lines without inserting new line number?

I am using the following snippet to insert C/C++ code into my LaTeX document but the problem is that the code on one line is too long and it goes over the right side of the document page. How to split ...
3
votes
1answer
57 views

Where's the mandatory argument of sectioning commands?

I was looking in the file book.cls and I noted there is no mandatory argument in the definition of \section, \subsection, and \paragraph commands \newcommand\section{\@startsection {section}{1}{\z@}% ...
1
vote
0answers
25 views

Math mode code indentation [duplicate]

How is math mode processed in TeX? Is typing \n (in editor) in math mode equivalent to one space? I am asking, because I struggled to find a bug in source code (between a lot of matrices :-) ), and ...
1
vote
1answer
113 views

Writing pseudocode for parallel programming

"How do you write pseudo-code for parallel programming? Especially, how do you differentiate local and shared variables? How do you represent operations like scatter, gather, reduce, broadcast, and ...
0
votes
1answer
71 views

Rename an environment: the codeexample used in tikz

I try to rename environment codeexample used in tikz document, but fail to use the tricks as in Wrap an environment. This is related to tkzexample: source and output side-by-side. The pgfmanual-en-...
2
votes
1answer
48 views

Wrap an environment

The following codes are taken from source and output side-by-side \documentclass{article} \usepackage[skins,listings]{tcolorbox} \newtcblisting{exampleB}[2][]{% colframe=red!50!yellow!50!black, ...
1
vote
0answers
94 views

Is it possible to get the latex version rather than pdf version of papers? [closed]

I am going to learn latex, I think the quickest way to do it is to imitate good latex examples. The latex version of the published papers are excellent examples, is it possible to download the latex ...
1
vote
1answer
57 views

How to make annotation to code listings

Is it possible to make annotations to source codes like below?
0
votes
0answers
37 views

Must PDF always eat source code indentation? [duplicate]

The packages listings and minted present source code inline. My publication target is PDF. From my own documents as well as from the documentation for those two packages, copying and pasting the ...
1
vote
0answers
34 views

Bring several lines together to fill blank spaces in TeXmaker

Suppose in a TeXmaker document that looks like something like phrase 1 phrase 2 phrase 3 phrase 100 or a sentence that looks like A quick brown fox jumps over the ...
1
vote
1answer
41 views

What is the correct code this algorithm in latex

\documentclass{article} \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \makeatletter \def\BState{\State\hskip-\ALG@thistlm} \makeatother \begin{document} \begin{...
0
votes
0answers
41 views

Minted package does not recognize lexer inside listing

I have a problem with the minted package. I am using two different lexers, juliaand jlcon. The first one properly highlights code, but the second one only works if the code is not inside a ...
1
vote
1answer
42 views

pgfplots: Are parentheses mandatory in axis environments?

Assumed we have this little code snippet: \begin{tikzpicture} \begin{axis}[ date coordinates in = x, table/col sep = semicolon, date ZERO ...
7
votes
4answers
964 views

Two spaces in LaTeX code

I have a simple question: does it make any difference whether at some point I have two spaces instead of one in the source code, say after a period? That is, will PdfTeX ever output different things ...
1
vote
2answers
58 views

How can we Define our own Simple Environment for Source Code?

Inside of our document we wish to define a new environment for blocks of source code \newenvironment{srcblock}% % Define the environment Later, we will use the environment: \begin{srcblock} % use ...
0
votes
1answer
68 views

What is the advantage of using a pseudocode package instead of simply putting code inside of a verbatim block? [closed]

What are the advantages of using a pseudocode package (like algorithm2e) above simply putting code inside of a verbatim block? Edit: In order to make the question less vague, I will say this: ...
2
votes
1answer
60 views

Hebrew within sourcecode

I need to include LaTeX source code, which contains Hebrew text, within an Hebrew document. I tried doing so within a verbatim environment, but Hebrew words appear in opposite order. Any solution ...
2
votes
1answer
44 views

Problem inserting C snippet

I am trying to insert an snippet like this But when I write \usepackage{listings} \lstset{language=C} \begin{document} \begin{lstlisting} typedef double real_t; // Esto casi seguro necesita ser tipo ...
3
votes
2answers
285 views

Add keywords at the bottom of a document

I want to use \documentclass[12pt,a4paper]{article} in the place of \documentclass[12pt,reqno]{amsart}. However I want to add the following in the bottom of the first page This is my codes \...
0
votes
2answers
46 views

Reducing space in the Table of Contents

I'm using the following codes \documentclass[12pt,a4paper]{report} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Useful Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %---------------------math--------...
0
votes
1answer
77 views

remove all insignificant whitespace from tex source

Is there an existing tool for removing all insignificant whitespace from the source of a tex document? I'd like to run this before calling latexindent to see if I can have an autoformatter tool that ...
1
vote
1answer
33 views

The bottom of the first page of a report

I want to obtain the bottom of my first page of my report like the following Could you please help me with the necessary codes? My attempt: \documentclass[12pt,a4paper]{article} \usepackage{...
4
votes
1answer
486 views

How to use true/false inside definitions?

Suppose you want to define page style depending on a boolean value. I think both constructions below have equivalent output (or not?), but which is better/more indicated/professional/elegant? \if@...
2
votes
1answer
55 views

Documentation of loop over item

In this answer there is a loop construct used called loop over item. I am looking for a documentation of this and for a reference in which file it is defined. \ifdate{workday} { \tikzset{every ...
10
votes
1answer
252 views

LaTeX Uglifier / obfuscator

For JavaScript you have e.g. js uglifier, which obfuscates the javascript so that it is infeasible for humans to read the javascript code. Also, judging by @DavidCarlisle's xii.tex (see below), ...
2
votes
1answer
95 views

How do I get separate source code functions in one line?

It it difficult to create a question for this. I want to tex source code like here. Is this with listings? Which package do they use? How do I get the separate procedures in one line? And how do I get ...
6
votes
1answer
507 views

How to embedded source code on-demand into PDF?

I wondered if its possible to embed source code of some software you are writing about into the PDF but not displayed by default. E.g. you have a long script I would be nice if the user/reader could ...
0
votes
1answer
212 views

How to import Java source code from multiple folders to LaTeX

I want to add all my Java source code to an appendix. But I have 20 projects. Is there a possibility to just tell LaTeX where the folder with the different projects are, and LaTeX collects all the ...
2
votes
1answer
317 views

LaTeX convention how to indent source? [closed]

I am new at LaTeX and I am asking myself at the moment if there is a convention how to indent the source code. For example: \begin{itemize} \item erstes Stichwort \item zweites Stichwort \end{...
1
vote
0answers
159 views

Minted vs matlab-prettifier for thesis [closed]

I am writing my PhD thesis now for which I need to list snippets of source-code within the main text and full listings in the appendix. I did my coding entirely in MATLAB using advanced constructs ...
1
vote
1answer
289 views

Lyx source code from tex extension to lyx

A friend sent me a lyx file to edit it. I had no idea how lyx works so I assumed it was similar to the usual latex. Since I hadn't lyx installed, I opened with texmaker as a .tex file and edited. I ...
6
votes
1answer
70 views

How to emphasize in a listing and keep source columns aligned?

I use moredelim with * to highlight some text in my lstlisting. \documentclass{article} \usepackage{listings} \usepackage[LY1]{fontenc} \renewcommand{\rmdefault}{ptm} \renewcommand{\ttdefault}{...
1
vote
1answer
71 views

Malformed dots when using listings

How is it possible to compile such page? \begin{lstlisting} ⡂⡀⣀⢀⣄⡀⣰⡉⡀⠀⡀⡀⣀⠀⢀⣀⢀⣄⡀⡂⢀⣀⡀⢀⢀⡀⠀⡰⣀⠀⣀⠀⡂⡀⣀⢀⣄⡰⡀⢠⠂ ⡇⡏⠀⡇⡇⠀⢸⠀⡇⢀⡇⡏⠀⡇⣏⠀⠀⡇⠀⡇⣏⠀⣹⢸⠁⢸⠀⡇⢈⠷⡁⠀⡇⡏⠀⡇⡇⠀⡇⢼⠀ ⠁⠁⠀⠁⠈⠁⠈⠀⠈⠁⠁⠁⠀⠁⠈⠉⠀⠈⠁⠁⠈⠉⠁⠈⠀⠈⠀⠱⠉⠀⠉⠀⠁⠁⠀⠁⠈⠱⠁⠘⠄ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀...
0
votes
1answer
75 views

go to source is not working with dvi-ps-pdf-chain in texstudio 2.10.8

I am using eps figures and and I want to put them into my latex file. everything is working with choosing dvi-ps-pdf-chain except "go to source". when I use this "go to source" is disappeared. It is ...
1
vote
1answer
331 views

Code validation in minted package? How to disable it?

I'm using minted for inserting syntax highlighted HTML code in my document. But it isn't simple HTML (valid HTML I mean) and has some special characters and definitions (if you're interested, it's ...
6
votes
2answers
300 views

Can one customize lstlisting environment?

I want to add some Python source code to my LaTeX document, but I want to apply some customization. Currently, I have something like this: \documentclass{article} \usepackage[utf8]{inputenc} \...
0
votes
1answer
89 views

Writing code for image [closed]

Can someone help me to write code for the following figure. I want to insert it in a presentation and am not well versed with graphics?
3
votes
0answers
666 views

Formatting bash with listings

I writing a documentation in LaTeX about Linux Bash resp. Shell script. And I'm having some problems: How can I start a formatting at the beginning of a line? How can I format between two signs, but ...
3
votes
1answer
191 views

LaTeX(2e) Programming vs. expl3 (which to learn)

Recently, I've decided it would be a useful and interesting skill to be able to program LaTeX classes, macros etc, and so had a look around about what resources existed (this question was very helpful)...
0
votes
2answers
64 views

How to have one code to be typeset both as final and as source code [duplicate]

I'm very limited in writing Latex code and I could not find how to solve my problem searching in the forum ou googling around. My problem: I have to write a document with many algorithms and show ...
3
votes
1answer
1k views

Using listings package with beamer/block environments for displaying source code

I use beamer with semiverbatim environment to show source code. \documentclass{beamer} \setbeamercolor{background canvas}{bg=yellow} \useinnertheme[shadow]{rounded} \setbeamercolor{block title ...
0
votes
0answers
71 views

Updating theorem number in tex file

I honestly do not know how to search for this feature. Recently, I had an experience with skylatex for proofreading. One of the features I really enjoyed was that once I compiled my source file, the ...
1
vote
1answer
393 views

How do I find the meaning of latex documentclass options?

I saw someone using the [final] option for the beamer documentclass and wanted to see what it did. So I searched the package documentation here on CTAN and also found the directory on my computer that ...
2
votes
1answer
154 views

How to achieve this two column style?

I’d like to add some code examples in two column form. The left is a description and the right is the REPL input code and output. Here’s an example of what I’d like to achieve: Are there well known ...
1
vote
1answer
44 views

Why ~ is not shown in place in R source listings? [duplicate]

My sample code is- \documentclass{article} \usepackage{listings} \usepackage{xcolor} \begin{document} \lstinputlisting[numbers=left,backgroundcolor=\color{lightgray},language=R]{code.R} \end{document}...
1
vote
1answer
84 views

Scantokens and Newlines

I'm having problems with the usage of scantokens. I'm trying to convert a list that I read in while under the effects of \obeylines. For some reason, any time I use scantokens on my list, it stops ...
2
votes
1answer
390 views

Reading LuaTeX source

TL;DR: I want to read the source code of LuaTeX. How and where? I want to know exactly how the Knuth-Plass algorithm for line breaking is implemented in LuaTeX. Not an explanation, I want the source. ...
0
votes
1answer
2k views

How to paste source code into LaTeX with correct indentation

I am trying to use \begin{lstlisting} ... \end{lstlisting} to include some Python source code in LaTeX. When I paste the following code block: def plot_c(Yhat, Y, X): plt.figure() plt....
9
votes
1answer
227 views

Is there a newmarks command?

Is there a way to allocate the e-tex marks with names, similar to things like \newtoks? It shouldn't be too hard to implement, I just want to know if it exists already. To be clear: e-tex makes ...
4
votes
1answer
133 views

Where one can find an old version of `table` environment

This question is a result of an answer to Table captions do not appear on top in IEEETran class As far as I remember, a long time ago the caption for a table was always in a proper position. It was ...