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

learn more… | top users | synonyms

0
votes
2answers
227 views

TeX Programming questions (and stuff about parcolumns)

I'm trying to modify the inner workings of parcolumns. I'm starting to understand the TeX macro "programming" language a bit but I have some issues. In paracolumns there are three issues I want to ...
4
votes
2answers
613 views

How to check if a font exists in XeLaTeX

Is there a way to check if a font exists in XeLaTeX? I am aware of Check for missing fonts/characters in XeLaTeX?, but sadly the one answer only refers to the log. I am interested for a test via code. ...
18
votes
2answers
1k views

Programming simple functions using TikZ arithmetic?

How do you do program simple functions using the TikZ arithmetic engine? I love the idea of using TikZ in order to “program” my pictures, being able to write code once and reuse, get precise ...
8
votes
2answers
264 views

Why are some macros undefined inside an if case?

I'm trying to check if a string is only of one char, and I ran into this problem: LaTeX complains that \StrLeft in the comparison takes and additional argument: ! Argument of \@secondoftwo has an ...
3
votes
2answers
245 views

Taking user input during compile

Deeply inspired by Paulo Cereda's answer on the ways TeX can be used apart from document creation. If you haven't seen the program mentioned: it's a Reversi TeX game that during the compile asks the ...
10
votes
1answer
318 views

Storing and retrieving data in tuc file

I want to store some data in the .tuc file, which is being picked up in the next run. I suceeded in storing some values but I failed in retrieving them afterwards. Here is my attempt: \starttext ...
4
votes
1answer
117 views

Summary based on environments/custom commands

Suppose I am taking notes in class and label certain things with my own environment like: \begin{Theorem} Important Theorem Here. \end{Theorem} or smaller key ideas labeled with my own command ...
8
votes
2answers
194 views

\CatchFileDef vs ( \input or \@@input )

I discovered catchfile here and now I would like to understand how works this package. Below some tests with \foreach or \@for \documentclass{article} \usepackage{filecontents,catchfile,pgffor} ...
7
votes
2answers
266 views

how to test if tikz library is loaded

I want to write some demo code showing code with examples for tikz. However I want the resulting pdf to be automatically depended on the tikz libraries and therefore I must test which are loaded. Is ...
4
votes
4answers
421 views

Writing a multiple option command for a package

I am a newbie at LaTeX programming, so please be patient. :-) I am writing a .sty file which I want to include a command \dan which is overloaded with three separate versions depending on whether ...
7
votes
1answer
230 views

Why do some arguments in a macro need to be preceded by \noexpand?

I keep on studying the use of nested tikzpicture environments (sorry) and I discover the next problem. I'm not sure but it sounds like a problem with "fragile" commands. Perhaps, the problem is the ...
13
votes
3answers
743 views

Use \bgroup and \egroup to set some pre and post code to a macro

Why isn’t it possible to use \bgroup and \egroup in this way? \documentclass{article} \def\precode{\fbox\bgroup} \def\postcode{\egroup} \newcommand{\mymacro}[1]{\precode#1\postcode} ...
12
votes
2answers
351 views

How to emulate some options of \node from TikZ

Code \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \a in {0,45,...,315}% {\node[line width = 0pt, rotate = \a, anchor = ...
34
votes
2answers
1k views

Implementing a pullquotes algorithm in LaTeX

In pullquotes, I provided a manual technique for typesetting pullquotes in LaTeX. The technique was to typeset the material in two long narrow columns and then position them so as to join them ...
31
votes
5answers
814 views

Stack datastructure using LaTeX

A very common programming data structure is a stack. A stack is simply a one dimensional array. Stack elements are pushed in or popped out of the stack one at a time as LIFO (Last In First Out). I ...
6
votes
1answer
319 views

Problem with keys to emulate \rput with TikZ

This is a beta version of \rput with TikZ. I don't know if the psticks version accepts polar coordinates but I added this option. My problem is to add the options ref = B, Bl , Br, t, tl , tr, b, bl ...
4
votes
1answer
115 views

how to use \@Alph in the name of node inside a foreach?

In this question we use a lot of possibilities to define a cube. One idea is to name the vertices. I would like to find something to create these names automatically. In my last example in the ...
97
votes
5answers
9k views

LaTeX3 versus pure Lua

Reading this site for the last nearly two years I've learned a lot about LaTeX3 (which I had previously understood to be a defunct pipe dream) and LuaTeX (of which I was previously totally unaware). ...
11
votes
2answers
4k views

Remove space after command

To simplify some text I created some commands. One command has no arguments. It uses math mode but is used inside normal text. I would like to remove any trailing space between the command and ...
18
votes
3answers
1k views

Is it possible to generate sudoku games with LaTeX?

I am a fan of sudoku and I was wondering if it is possible to randomly generate sudoku tables with their solutions in LaTeX. I see a few problems in the generation of numbers in the tables, but, ...
13
votes
1answer
494 views

Why is \input not expandable?

In latex.ltx I found \def\input{\@ifnextchar\bgroup\@iinput\@@input} where \@@inputis expandable. I would like to know if there is an expandable version of \input. The problem comes from an example ...
2
votes
1answer
159 views

How to mimic BibTeX change.case$ built-in command? [duplicate]

Possible Duplicate: Capitalizing strings ignoring closed class words Neither bibtex.exe nor bibtex8.exe can handle unicoded database properly. Newrtheless some peoplу (and me too) do use ...
54
votes
6answers
3k views

Does TeX/LaTeX give a headstart with other programming languages?

I've seen many programmers here at tex.se, and I'd like to know how they view TeX/LaTeX as a programming language in relation to other languages, and whether it would boost my progress as a beginner ...
6
votes
1answer
651 views

Generating a worksheet

My objective is to be able to generate worksheets in categories like: Laws of Indices Simultaneous Linear equations and Quadratic equations When I say generate is to generate for example 20 ...
4
votes
1answer
540 views

Creating random problems by using rand option

I would like to generate random questions based on a random integer input. I have tried he code from a site online and tweaked it so that it generates more than one random problem but evidently it ...
1
vote
1answer
253 views

keyvalue with kvoptions and switch structure

I am using kvoptions for a key-value syntax. However I need a switch syntax for the evaluation. Since boolexpr is problamatic (see here) I use now the other solution of this question. However the ...
8
votes
1answer
290 views

Arguments delimited by blank space in a macro

I work on postscript objects and I need to transform lines like 109.8516 58.404 moveto 102.7108 70.7583 88.4258 67.3824 82.4704 64.0235 curveto or 109.8516 58.404 m 102.7108 70.7583 88.4258 ...
7
votes
1answer
123 views

How to use the primitive \the with dimen?

I know that I need to put an internal quantity after \the. I know the expansion is a list of tokens of catcode 12 (except for space characters). I know the next problem : \skip0=30pt plus 2pt\relax ...
3
votes
1answer
187 views

How to get Carriage Return instead of ^^M when I save a file

Sorry for the long next code but if I modify a part of the code, another problem appears in another part. The idea is to use an environment to catch an example, then I display the code of the example, ...
15
votes
3answers
435 views

How to trim .tex for each filename read from an external file?

I have an external text file that contains a list of names of TeX input files. The names have trailing extensions .tex. For example, the external text file named data.txt contains the following list: ...
7
votes
3answers
261 views

How to allow blank spaces between arguments of a macro

For example, I would to write \defpoint [option] (1,2) {A} instead of \defpoint[option](1,2){A}. What is the best way to build this kind of macro? Only the argument [...] is optional and if spaces ...
11
votes
2answers
285 views

Where is the argument?

I have this code on my hard disk and now I would like to understand it. Firstly I would like to know if this code is correct and logic or if there is another way to do the same thing. ...
4
votes
2answers
314 views

Solutions to problem sheets

For writing problem sheets I have a customized theorem environment called pr for the problem and a specialcomment called solution for the solution. See example below. Now my question is, if it is ...
5
votes
1answer
463 views

Use a loop to generate a list for another (foreach) loop

Is it possible to use a loop to generate a list for a foreach loop? More specifically I want the following: Consider the following answer to a question I asked some time ago: ...
8
votes
2answers
277 views

How do I redefine a macro when any group begins, then again when that group ends?

Okay, I know this is a pretty tall order, but I'm working on a package based on my answer here, and I'm including Ahmed Musa's environment which redefines \par. The problems are: Some environments ...
2
votes
1answer
125 views

Check if multiple column types are defined fails

Using the commands of the discussion How to check if a column type is defined? and How to implement a command that checks for loaded packages? I have build an enviroment to check if more than one ...
5
votes
1answer
207 views

Show or hide rows of a tabular controlled by a global variable

Is it possible to show or hide rows of a table by setting a global boolean variable? \documentclass{minimal} % some boolean variable X \begin{document} \begin{tabular}{ccc} A & B & C \\ A ...
16
votes
2answers
2k views

Draw a prism in TikZ or PSTricks

Is there a way to define an polygon in plane and output an (orthogonal) prism with that polygon as its base? The prism should be drawn in 3D in parallel oblique perspective with controllable height h, ...
7
votes
4answers
444 views

Apply formatting to outermost parentheses

I have some text information where I need to apply a text format to all the outer most parentheses such as making them larger and/or bold. In a sense I want to process text like ...
8
votes
6answers
881 views

Parse simple arithmetics and return the result

I want a command \ca which takes a simple arithmetic calculation as an argument and returns the result with proper decimal places. Additionally I want an boolean argument which decides if only the ...
6
votes
1answer
8k views

Using string variable with LaTeX

I would like to define one variable containing some text that can be changed locally. The following code gives one example of the featuring I'm looking for. \documentclass{article} ...
3
votes
1answer
406 views

latex @temps(wa) commands

I would like to know more about the temporary commands of LaTeX, such as \@tempa, \@tempswatrue especially for the following construct, where I wonder if my replacement is correct: % Provide bool for ...
10
votes
3answers
727 views

How to implement a command that checks for loaded packages?

I use the following code to check if a package is loaded: \RequirePackage{ltxcmds} \newcommand{\IfPackageLoaded}[2]{\ltx@ifpackageloaded{#1}{#2}{}} However, sometimes I want to check if more than ...
7
votes
2answers
1k views

Passing arguments to \def inside \newcommand (TikZ/PGF)

I'm having trouble passing an argument to \pgfmathparse inside a macro I defined. Here is the code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\drawmestg}[2]{ ...
2
votes
1answer
228 views

Call macro whose name depends on macro

Sorry about the title, I really couldn't find a better one. I'm facing the following dilemma: I'm using the smartref package, in particular I'm using its \sgetXval macros. The thing is that I'm using ...
11
votes
1answer
2k views

Note page showing the next frame

I would like to customise the note pages in Beamer to show: the current frame that they refer to with its number, the next frame of the presentation with its number, the section and subsection, the ...
5
votes
2answers
2k views

How to pass definitions to \AtBeginDocument?

I need to delay execution of a chuk of code to the time when other packages are loaded so I wrap it into \AtBeginDocument: \AtBeginDocument{% \def\reserved@a#1#2{% \edef\reserved@b{#1}% ...
0
votes
2answers
190 views

Conditional \endinput

I want to prevent processing rest part of a package in case if it is loaded not from lualatex. For some reason I cannot load ifluatex package, so I borrowed definition of \ifluatex from that package ...
6
votes
1answer
434 views

Can luaLaTeX convert xlsx tables into LaTeX code?

Inspired by this question: Using external tables in TikZ, I would like to know whether it is technically possible to use a xlsx (Office Open XML) file directly with luaLaTeX, i.e. can luaLaTeX call ...
5
votes
1answer
2k views

TeX capacity exceeded

The following is a minimal example which demonstrates my problem. The error TeX capacity exceeded, sorry [input stack size=5000] \end{latexresult} is depending more or less on the number of ...