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
0 votes
0 answers
29 views

what's the point of % before line breaks? [duplicate]

I see this pattern of %(s) before line-breaks a lot in packages. What's the point of it? Is it necessary or a convention? For example: \newenvironment{blah}{% some command% some other command% }
user avatar
  • 1
1 vote
1 answer
80 views

Overleaf: "fontspec all the fonts!": LaTeX source?

Is there a LaTeX source available for the following pdf? https://www.overleaf.com/latex/templates/fontspec-all-the-fonts/hjrpnxhrrtxc Or at least an old version? Or something similar (a document with ...
user avatar
  • 114
0 votes
1 answer
48 views

How to render a long code listing in multiple pages with the package minted?

I'm using the package minted for formatting code in my paper. The package minted provides a "listing" environment, which treats the code inside it as a float. It works very well under most ...
user avatar
0 votes
0 answers
25 views

Disable automatic indentation in TeXShop source code

While writing source code in TeXShop, hitting enter normally causes the source to start a new line which is automatically indented as much as the previous line. I'm well aware that the automatic ...
user avatar
  • 101
0 votes
0 answers
70 views

How to make a personalised ruler?

I wanted to know if and how would it be possible to create a personalised ruler in LaTeX. "Personalised" means I would like to create something like the "famous" IMPERFECTO ruler, ...
user avatar
  • 308
1 vote
0 answers
32 views

How exactly are parentheses (and other special symbols) rendered in LaTeX? How do they relate to the font used in the document?

I am compiling this sample document: \documentclass{article} \begin{document} \(\sqrt{\left(\frac{2}{3}\right)}\) \(\int_{a}^{b} \sqrt{\left(\frac{2}{x^2}\right)} \,dx\) \(\left(\frac{2}{\frac{2}{\...
user avatar
  • 111
1 vote
1 answer
52 views

Listing for file folder-structure as text not working

For my documentation, I need to provide a way on how to structure some Python code in a project. My approach to show it was to simply use a structure of text like this: app/ ├─ ... ├─ controllers/ │ ├...
user avatar
  • 159
0 votes
0 answers
157 views

How to fix " Shipout\background/foreground problem?

I find a similar question here here But I am unable to solve my problem. And also I do not have the idea to update my latex. Currently, I am using the latex version 3.14159 -265-2.6.40.19(MikTex 2....
user avatar
  • 229
1 vote
1 answer
34 views

Listings show Quotation marks in italic - how to print them in Regular?

I use the listings package for showing source code. I just realized, that double and single quotation marks are printed in italic - they should be printed in regular instead ... Where is the issue? Is ...
user avatar
  • 159
0 votes
0 answers
28 views

Latex error message

I get this error message when running a markdown program. I am trying to knit to a pdf and for the tangram package, Lancet is a style I need for a report. ! Undefined control sequence. l.79 \...
user avatar
0 votes
0 answers
53 views

How can I make for an environment to remain contracted?

When I am editing my document in TexMaker I can do the following But when I close TexMaker and I open it after, it occurs that the theorems and definitions don't remain contracted, how can I make for ...
user avatar
1 vote
1 answer
48 views

Horizontal spacing in document class book

Here is my document from the beginning: \documentclass[11pt, openany]{book} \usepackage[utf8]{inputenc} \usepackage[a4paper, margin=1in]{geometry} \usepackage[T1]{fontenc} \usepackage{lmodern} \...
user avatar
  • 353
2 votes
0 answers
146 views

Produce copy-paste friendly code blocks in PDFs

I have used lslisting for inserting the code blocks. Requirement is to make the code blocks displayed correctly in the compiled PDF and make them as easy as possible to copy as plain text. Please take ...
user avatar
0 votes
0 answers
55 views

How to compile a complex file

I just would like to know what do I need and how I can compile a template given in this form on GitHub: https://github.com/tetrapharmakon/mycv. I am using TexShop on a Mac. I am a beginner with LaTex, ...
user avatar
  • 343
2 votes
0 answers
124 views

How can color of a default parameter in call, be changed like PyCharm?

I am working on a document that contains some Python codes. I use the following template in Overleaf. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{xcolor} %...
user avatar
  • 121
0 votes
1 answer
48 views

How to retrieve source code of mathchar?

I'm looking for source code of mathchar ∈, latex \in. I want to modify it for my own use.
user avatar
  • 33
3 votes
1 answer
2k views

Import source code from Overleaf in Texstudio

I have downloaded the source code from the "Overleaf" of my thesis project. Now I want to edit and work on it with a local TeX editor, e.g. TexStudio or Texmaker. The source code contains ...
user avatar
  • 33
1 vote
0 answers
115 views

Change color of a word in .tex code (TeXstudio)

I would like to change the color/highlight the background of a certain word in the source code of a .tex file in Latex (TeXstudio). This is for editing purposes, and I don't want it to output to the ...
user avatar
  • 11
0 votes
1 answer
148 views

How can I split LaTeX source line into multiple lines?

I want to split LaTeX source line Some text I would like to have in one line~\footnote{ something explained } into something like: Some text I would like to have in one line\ ~\footnote{ ...
user avatar
  • 205
0 votes
0 answers
62 views

What is the option I should use for basicstyle in \lstset if I want Times New Roman font in source code?

I copied the following from somewhere in Internet to the beginning of the latex document to enable math escape in source code listing : \usepackage{listings} \lstset{ basicstyle=\ttfamily, ...
user avatar
0 votes
2 answers
127 views

Provide Students with TeX Question Template

I am an instructor, and I prepare homework assignments using the \documentclass{exam}. I know that when I compile to PDF I can use \documentclass[answers]{exam} to generate a compiled PDF that ...
user avatar
  • 249
0 votes
0 answers
330 views

How could I use .bak file?

I used WinEdt 10 for making tex, but today I found the tex file empty. I found a bak file on my desktop, but I don't know how could I use that. I tried changing .bak to .tex, but it didn't work.
user avatar
  • 57
1 vote
1 answer
2k views

How to create this beautiful Python highlighting in LaTeX with listings?

I found this beautiful Python code highlighting in a PDF today. I want it! But I don't know how to get it? Here is what I tried: \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \...
user avatar
0 votes
1 answer
306 views

Break longer word into lines to fit the box (inputminted?)

I would like to fit the long string (as it is labelled url in the json file) inside the box without overflowing. As far as I understand, breaklines option only helps when strings consist of separated ...
user avatar
  • 160
0 votes
1 answer
67 views

How to reproduce this title inside of a box

I'd like to produce something like this at the beginning of my document: a box with a centered title and details in the angles like the date, the author, etc. What's the code that produces this output?...
user avatar
  • 568
1 vote
0 answers
37 views

Beamer: code fragment with listings [duplicate]

I am having difficulty adding code fragment to my slides in beamer with listings package. My code: \documentclass{beamer} %\usepackage[utf8]{inputenc} \usetheme{Warsaw} \usepackage{listings} \title{...
user avatar
  • 329
1 vote
2 answers
701 views

Automatic LaTeX code formatting (similar to clang-format)

There are tools such as clang-format that take e.g. an "ugly" (unformatted) C++ source code file and apply specific indentation and other rules to make the code more readable. Is there such ...
user avatar
  • 211
0 votes
0 answers
64 views

List of best LaTex Editors in 2020 [duplicate]

There are plenty of people who still raise this concern, Since I too use such editors, I’ve compiled this list of best LaTex editors with good facilities and features. Here are the top ones that I ...
user avatar
4 votes
2 answers
389 views

Can someone explain what is labxx in the source code of tex

As shown above, I saw many labXXX in the source code of tex and pdftex. I'm really confused about them and there is no comments at all. Is there any doc that demonstrate the meaning of every labXXX? ...
user avatar
  • 471
1 vote
1 answer
142 views

Can I organize my figures in separate .tex files and insert them into my main document?

I'm writing a long paper, I have to add many figures, and the code lines for adding all those figures in my paper makes the code hard to read. Is there a way to for example create a figure1.tex ... ...
user avatar
0 votes
0 answers
95 views

What is the language used in LateX?

I'm writing a book with LateX since few months ago and I used some blocks of code as black box for me because I don't know the language of LateX, and I can't solve some problems because of my ...
user avatar
  • 367
0 votes
0 answers
76 views

This simple code just won't compile

This is the code: \documentclass{article} \usepackage{amsthm} \begin{document} \begin{proof} \end{proof} \end{document} This is the error I get: This is pdfTeX, Version 3.14159265-2.6-1.40.19 ...
user avatar
  • 568
0 votes
1 answer
144 views

Is (( \usepackage[T1]{fontenc} )) responsible for the python font in PDF code cells?

I'd like to make my PDFs stand out so I'm trying to change the default Python font that gets used in the code cells when exporting PDFs with nbconvert. I was exploring in article.tplx and found ...
user avatar
  • 101
1 vote
0 answers
28 views

Robust source search for Tex-sourcecode

We use latex in the backend of a web application which stores exercises. To make exercises easier to find, we thought about implementing a source-code search. But we stumbled upon a lot of problems ...
user avatar
  • 173
0 votes
1 answer
58 views

latex/listings extend/add to a literate rule

I was looking at this question here Listings: syntax for literate but when I try the mew of the solution, it crashes if I insert special characters like the German ä. Since these should be escaped by ...
user avatar
  • 393
1 vote
1 answer
147 views

How does `\autoref` (from the package hyperref) know what type of labels I am referring to?

I have been digging the source code of \autoref for quite a while, but haven't understood the way \autoref determines the types of labels. I am sort of lost in the relevant code (hyperref.dtx line ...
user avatar
  • 171
0 votes
0 answers
515 views

TeX source code is just black instead of including red/blue/green elements

I have a simple question. I am writing a document in the Overleaf editor with multiple chapters in different .tex files, and in one of the chapters the source code looks like this: However, in my ...
user avatar
  • 1
0 votes
1 answer
626 views

keeping the color of the source code in latex

Any idea how can we keep the color of the python code we copy into latex? Please note I don't want to define the colors in Latex. Just want to keep the same colors shown in IDLE when I copy the code ...
user avatar
  • 3
0 votes
0 answers
126 views

How to keep the source code in order

My first documents were very simple - just few rows of preamble and then the document content with the default settings - but most of my current projects require much more setup and the source code ...
user avatar
  • 601
5 votes
2 answers
600 views

LaTeX code formatting regarding placement of floats and where best to place figures with respect to main body text references

I have seen a number of articles, questions, and comments over the years that recommend when using floats such as tables, figures with captions, and so on, that the best thing to do is to let LaTeX ...
user avatar
  • 349
2 votes
2 answers
5k views

what package should I use for $\mathscr{C}$?

What package should I use for $\mathscr{C}$ to function? any help will be appreciated. My LaTeX file contains this: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \...
user avatar
1 vote
1 answer
1k views

Minted line numbers outside frame and outside margin

I have a code snippet where I use minted for nice display: \begin{figure}[H] \begin{minted}[ frame=single, obeytabs=true, tabsize=4, linenos, numbersep=6pt ...
user avatar
  • 257
2 votes
1 answer
111 views

Why is comparison between number and numeric argument not working in \ifnum and \ifdim conditionals?

I was modifying \@ssect command to edit \section* appearance. First I passed a further argument to \@ssect \def\@ssect#1#2#3#4#5#6{%... then I edited the dependencies in \@startsection by modifying \...
user avatar
  • 1,279
0 votes
1 answer
1k views

Formatting Matlab file with lstlisting

I included a Matlab file, and it worked fine. The colors changed and it looked nice. Suddenly Latex doesn't change the colors of the code, except of the background color. Is something wrong with my ...
user avatar
0 votes
2 answers
94 views

How to get the following output?

How to get the following output (without manually adding space)? I guess I should use the align environment but I can't get the domain and the codomain centered with the respective elements in the ...
user avatar
  • 568
3 votes
0 answers
284 views

latexindent and trailing comments

In macros it makes sense to put percent signs at the end of line in order to avoid any line break characters in the macro definition. For example, a macro with a multi-line definition could look like ...
user avatar
4 votes
2 answers
83 views

What does the comment-pln code actually do?

The comment-pln code on CTAN (link) defines the plain TeX macros \begincomment and \endcomment, that ignore everything typed in between. The entire code base is included below: % Comment.tex % ...
user avatar
  • 20.1k
0 votes
0 answers
25 views

Tabular With Code - "<" and ">" Are Not Recognized [duplicate]

This table \begin{tabular}{ | l | l | } \hline Ausdruck & Wert \\ \hline int x = 49; & -- \\ \hline !(x >= 0 \&\& x < 50 || x > 50 \&\& x <= 100) & true \\ \...
user avatar
  • 135
0 votes
0 answers
39 views

Output position in sourcefile of a macro expansion

Suppose I have a custom macro defined with \newcommand (no fancy parsing going on). For simplicity assume \newcommand{\mymacro}[1]{#1} Is there a way to redefine the macro so that, every time the ...
user avatar
  • 14.6k
3 votes
0 answers
547 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 ...
user avatar
  • 141

1
2 3 4 5
7