Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programming]

{programming} is about how (La)TeX can be used as a programming language.

0
votes
0answers
42 views

Embedded picture with separate coordinate system (Tikz)

Am using Tikz, and have a slightly complicated drawing. Now I want to replace a rectangle in a certain place with a more sophisticated shape. This shape I have in SVG format, and I want to replace the ...
3
votes
1answer
46 views

Use array/list/sequence for repetitive code?

For a PhD thesis cover template in our university, there is some code as follow: %%% Jury member n1 (Président) %%% \newcommand{\jurynameA}{M. Cabot} \newcommand{\juryadressA}{Someplace} \newcommand{\...
2
votes
1answer
40 views

How to expand condition on \IfEqCase before evaluation?

I'm trying to do a simple task (as in the MWE below). When a given text is given (a filename) it outputs a given color. To work as I intended, \IfEqCase should only evaluate the file extension, as ...
2
votes
2answers
83 views

Know in which column am I in [closed]

it there a way to have a variable that returns in which column of my multicols environment am I in? Thanks!
0
votes
0answers
23 views

Is it possible to `\include`/`\input` a text depending on the language set on babel or polyglossia

I would like to know if it is possible to conditionally require, in a given document, the inclusion of a chapter or the input of a particular piece of text, depending on the language set on babel or ...
3
votes
2answers
38 views

Special treatment for first and last items in \seq_map_inline

It is rather common to have to apply special treatment for first and last items of a sequence. I wonder what the best ways to treat these cases in expl3's \seq_map_inline. For instance, suppose I'd ...
2
votes
2answers
88 views

How can I wrap this hard-coded image gallery into a new environment?

I'm building a gallery using tabularx and tikz, similar to image-gallery. Here's a snippet: \documentclass{article} \usepackage{tikz} ...
0
votes
0answers
36 views

Generalization of progressive downscaling of fontsize

Although the answers to How can I progressively scale letters? are functional in the restricted context of the post, I would like to extend it by asking for a programmatic solution to the more general ...
2
votes
1answer
83 views

Reflection in ConTeXt

The answer to ConTeXt: avoid enumeration items across pages was a nice introduction to modifying TeX before rendering, like HTML with JavaScript. \startsetups [userdata:itemize] \setbox\scratchbox\...
1
vote
1answer
44 views

Input variable as argument in metapost script?

I would like to pass input parameters into my .mp script. For example, instead of running: mpost script.mp I want to run something like: mpost script.mp 1 1 2 diamand Where "1 1 2 diamond" are 4 ...
2
votes
1answer
43 views

Extend book class with options of multiple values

I am writing a class based on book.cls, to which I want to have an option that is a list, so I can do \documentclass[languages={french, english}]{testops} I have define the key using l3key2e. But it ...
3
votes
0answers
50 views

Is it possible to build a pgf key?

Wondering if it is possible to do something like the below, ie. build the keypath using arguments or similar: \def\mymacro#1#2{% \pgfkeysvalueof{/someprefix/#1/#2}% } \pgfkeyssetvalue{/someprefix/...
0
votes
1answer
61 views

Convert TeX to a standard equation string [closed]

I'm currently programming in Javascript, I figured this would be the best place to put it. I'm very very new to TeX, in fact I discovered it within the past hour. I was wondering if I could convert ...
2
votes
1answer
28 views

\centering leads to cascade of errors

Context: I'm developing a title page (writing my own titlepage environment) and I'm writing my own \thanks command (to give me control over where I spew the footnotes). Not knowing how \footnote does ...
3
votes
1answer
182 views

Processing a math paper written in TeX to generate a summary

I'm interested in writing a program that can automatically process math papers written in TeX in order to generate summaries. I have partly finished one written in Python but it does not seem to work ...
5
votes
2answers
119 views

Macro losing value when exiting custom environment

I'm trying to define my own custom environment, and ran into this problem: When I set a macro inside the environment's start code, that macro loses its value at the end of the environment. To be more ...
0
votes
1answer
27 views

Designing the programming list block in LyX

I'm new to LyX. I'm trying to create a programming block of some PL which looks like in the picture bellow: Tried to look for some similar threads, bud didn't find any. How can I make make the ...
0
votes
1answer
76 views

LaTeX error: illegal parameter number in definition of \pgffor@b

I am trying to use a loop. The following does not work: \foreach \a in {no,has}{ \begin{table}[H] \footnotesize \captionsetup{width=.9\linewidth} \caption{text} \vspace{-22pt} ...
3
votes
3answers
171 views

How to more efficiently get code like this?

I have a folder containing files like these, 2007.pdf 2007_Q1.pdf 2007_Q10.pdf ... 2007_Q5.pdf 2007_Q6.pdf 2007_Q7.pdf 2007_Q8.pdf 2007_Q9.pdf 2008.pdf 2008_Q1.pdf 2008_Q10.pdf 2008_Q11.pdf 2008_Q12....
2
votes
1answer
64 views

How to rewrite the looping below with nested ifelse operators?

Could you rewrite the looping part just with nested PostScript ifelse operators? \documentclass[pstricks,border=1cm]{standalone} \makeatletter \def\scale{% \psline(100,0) \foreach \x in {0,...
4
votes
2answers
288 views

“Incomplete \ifcase” error depends not on the \ifcase but the integer at which it's evaluated

I have a puzzling Incomplete \ifcase; all text was ignored after… error in that the same \ifcase is fine if I evaluate it at the largest integer for which it's defined, but if I evaluate it at a ...
4
votes
1answer
163 views

How can I change the number of iterations from 11 to 3?

The simplified example given below currently uses 11 iterations just for drawing at most 3 stems (vertical segments). It seems that my code is not efficient enough so I want to reduce the number of ...
2
votes
1answer
41 views

Why does arrayjobx return the wrong elements of the bi-dimensional matrix I defined?

In the following MWE, I use package arrayjobx to define a 2x3 array \RowPayoffs, where I assign each element its value by referencing its (row, column). Specifically, I define \RowPayoffs(i,j)={Rij}, ...
3
votes
0answers
42 views

Efficiently setting category code for a range of characters

I kept thinking about using Cyrillic characters in command names with PDFTeX engine. It looks to me so far that if I stay with 8-bit encoding and assign category code 11 to all Cyrillic letters ...
1
vote
2answers
331 views

Node above other node fails with “cannot parse this coordinate”

I'm Alex stuying automation engineering and have to write my master thesis with tex. Until now, I haven't really used tikz or used a program to draw graphics and exported them to tikz. Now for the ...
1
vote
1answer
57 views

Save command result in other command

I am getting a value by a command. Now I am temporarily changing a saved variable which changes the command output. After I finished some code I want to reset the stored value if the value before the ...
1
vote
0answers
50 views

Processing latex? Ie get text bounding boxs etc

Im looking at the possibility of processing a latex document to get coordinates of element off the page. For example if I want to get the coordinates of an image, or a heading off a page and output ...
0
votes
0answers
63 views

Look-ahead on token stream?

Is it possible to have a macro check, if it is followed by a given pattern of tokens and produce different expansions depending on it? So far I have tried using code such as \def\conditionalAction#1#...
1
vote
1answer
104 views

Why are my exercise and answer references reading 10 (ten) too many?

%-------------------------------------------------------------------------- % \documentclass[english]{book} %-------------------------------------------------------------------------- % % \usepackage[...
5
votes
2answers
246 views

How to test if an expl3 function argument is an integer expression?

How can I test if an argument supplied to an expl3 function is an integer expression? If it's not and I call any integer related function an error is generated (! Missing number, treated as zero.). I'...
4
votes
2answers
114 views

Use N type for own macros

Background In LaTeX3 I’m programming some macros to store and read contents from a variable like \tl_set:Nn does. An thus I’m generating variants using the N type, which causes a warning. The warning ...
2
votes
1answer
30 views

Token list of counter values

I am trying to collect certain counter values in a list of tokens. Here is my naive attempt: \documentclass{article} \newtoks\list \list={} \def\addtolist#1{\global\list=\expandafter{\the\list #1}} ...
5
votes
4answers
188 views

Unwanted spaces in user defined structures and the uses of % [duplicate]

This question arise from my recent activity on user defined commands of various kind. In the answer to a recently posed question, @egreg pointed out to me the importance of not forgetting a % after ...
5
votes
1answer
118 views

LaTeX3 pad something unexpandable

I'm trying to implement the Gray code in LaTeX. The current setup works and outputs the following (the commas are for visual distinction): (intended output:) 0,1; 00,01,11,10; 000, 001, 011, 010, 110,...
0
votes
0answers
83 views

How to update my own packages?

At the moment I am starting to organize my documents a little bit better. For this reason I want to externalize some of my code into packages. Some of these are rather stable but some have to be ...
2
votes
1answer
230 views

Options in custom class [duplicate]

Consider the following class: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{sampleclass} \LoadClass[ paper=a5, chapterprefix=true ]{scrbook} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrbook}} \...
8
votes
4answers
325 views

How to trim a certain part of each character in a whole document?

Got inspired from a nice article titled "why All Caps is so hard to read", I want to produce the following result for my document. MWE \documentclass[preview,border=12pt,varwidth]{standalone} \...
1
vote
1answer
122 views

Execute external bash file

This is a follow up to Get write18 to execute after file parsing With the code \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx,grffile} \newcommand{\filename}...
1
vote
1answer
54 views

Get write18 to execute after file parsing

Follow up to Get write18 to accept / expand command I want to crop a pdf and print it. My \the\pdfshellescape is 1, so my shell-escape is working. My MWE is \documentclass[a4paper,10pt]{article} \...
4
votes
1answer
160 views

Get write18 to accept / expand command

I am trying to use write18 to crop a pdf. The code is \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \newcommand{\filename}{} \newcommand{\croppedfilename}{}...
1
vote
1answer
44 views

expl3: lowercase sequence elements with line break breaks

I have some short text (book author names) stored in a sequence. Some author names are long, and therefore I have to insert manually a line break (\\). In a specific case, I have to typeset these ...
2
votes
1answer
52 views

Break out of current scope [closed]

Consider the following pseudo-code: { Instruction 1 If condition -> break Instruction 2 } Do some more stuff Is there a way to do something like this in LaTeX? I am referring to the ...
3
votes
2answers
138 views

Question about macro parameter expansion

This question is just for my own understanding of how expansion works. I'm using the siunitx package in a document. In order to make sure that I'm consistant with myself, I try to write results of ...
0
votes
1answer
44 views

Toggle numbering method for theorem-like environments depending on nesting in a section or subsection

I have been thinking of letting the sections determine the numbering style of theorems and such, in the following sense. If there are subsections, the enumeration should be section.subsection.number, ...
0
votes
0answers
68 views

Why are there so many non-composable commands in (La)TeX?

Basically every time I start to do something non-trivial and try to remove repetition, I run into problems with non-composability of commands. Why are there so many non-composable commands in (La)TeX? ...
6
votes
1answer
135 views

Is it a bad idea to make a command with the same name as an environment?

So I have defined an environment {sseqpage} where the body of the environment consists of options to control the appearance of an image. If no body is present, then the image can still be displayed ...
2
votes
2answers
113 views

Put a unique code on every page

I want to create a form that will be later filled on paper. Some fields though are filled automatically (i. e. printed already when person receives a form). Here is an MWE for the form itself: \...
2
votes
2answers
65 views

How to reverse the path direction of \psframe?

I think there is a bug in \psframe that behaves differently when we compare it with other closed curves in PSTricks. The path direction of \psframe seems to be clockwise while that of other closed ...
2
votes
3answers
70 views

How to rename a dynamically created macro?

I can use \let to rename \curvepnodes to \ParametricNodes, \Pnodecount to \LastIndexP as follows. However, because \Pnodecount is generated dynamically inside \curvepnodes, I cannot move \let\...
0
votes
0answers
112 views

Compute image ratio based on the largest picture available in the document

Following this question I asked a few years ago, I'm looking for a way to find the width of the largest picture (in width) in my document. Typically, this requires a for loop and some TeX programming....