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

learn more… | top users | synonyms

14
votes
1answer
592 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
164 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 ...
56
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
752 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
922 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
294 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
311 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
128 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
200 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, ...
16
votes
3answers
503 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
279 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
300 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
352 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
514 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
294 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
144 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
229 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 ...
19
votes
2answers
3k 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
520 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 ...
9
votes
6answers
1k 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
11k 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
454 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 ...
11
votes
3answers
865 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
2k 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
262 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 ...
12
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 ...
6
votes
2answers
3k 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
207 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
475 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 ...
14
votes
2answers
644 views

Improving TikZ user interface

I am looking to improve both on the concept as well as the user interface for code used to produce visual progress charts. The figure represents activities and progress for the construction of ...
5
votes
2answers
255 views

how to write content of a command into a file

This question is a possible solution to question Code fails with Emergency stop, when using \expandafter\csname and such in listings, though not really an answer. I have defined a command which may ...
1
vote
1answer
717 views

Code fails with Emergency stop, when using \expandafter\csname and such in listings

I am further working on my code for LaTeX Examples. I want to use the package showexpl for the simultaneus printing of code and results. Unfortunately I get an '! Emergency stop.' ...
4
votes
2answers
243 views

TeX evaluates 'document' code in preamble

I have the error ! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.30 \AddDemo{text}{Sample Text} in ...
7
votes
2answers
353 views

how to compare two booleans?

I want to test if either inputenc or selinput are loaded. My problem now is to do complex boolean expressions and I have no clue how to do that with LaTeX. The basic code would be something like ...
13
votes
3answers
5k views

how to create switch structure comparing strings in latex

I want to process options that get passed to a package with kvoptions. The string is then saved in \bugs@errorlevel. I want to test if it contains one of [info, warning, error] and set a command ...
4
votes
1answer
189 views

forLoop does not accept negative step?

I try to use \forLoop for a countdown sequence: \documentclass{minimal} \usepackage{forloop} \usepackage{fmtcount} \begin{document} \newcounter{idx} \forLoop[-1]{10}{1}{idx}{\numberstring{idx}\\} ...
0
votes
2answers
327 views

Environment with customizable number of table columns

I want to make macros for drawing group of questions with same answers with customizable text, number of answers and design (column widths, alignment, etc.), like this: ...
25
votes
3answers
2k views

Convert any number to corresponding word

This is a wild one: can anyone write a code that converts a number into the corresponding word? e.g.: 4 -> 'four' 31 -> 'thirty-one' and so on. Obviously, it is not enough to build an array ...
26
votes
3answers
7k views

When to use @ in an \if statement

I am new to LaTeX and so this question might come across as rather basic. It might also reflect my biases/assumptions from my C/C++ programming days. I was seeing the code of the 'exam' class and ...
4
votes
1answer
636 views

stack.sty and \end{environment}

I'm writing a multilevel itemize list environment to simplify the process of putting nested lists in Beamer slides, and I want it to support enumerate lists as well. The mitemize environment is ...
3
votes
4answers
878 views

Generating dummy text programatically using TeX/LaTeX

As part of an attempt to debug another problem, I have a need for a TeX/LaTeX command that generates some dummy text in place. I know of lipsum and blindtext, but they are not what they want. What I ...
5
votes
2answers
1k views

How can one get a list of the available functions in Lua(La)TeX

Is there a list or method to determine a list of the lua functions available/installed? Sofar I could only find the lua source files. Maybe I should write something that search through all the ...
0
votes
1answer
378 views

Problems with error message when using listings-package and inputenc.

I want to include the code of some script in my LaTeX document. In a "minimal" example, it works perfectly well - but only if I leave out the line \usepackage[latin1]{inputenc}: ...
7
votes
2answers
3k views

How to typeset VBA code in LaTeX?

I have a lot of VBA (Visual Basic for Applications, the programming language in Microsoft Office) code which I have to add to my thesis in the appendix. I wonder how I can most comfortably list those ...
2
votes
1answer
188 views

How can I display nested lists (the programming-datastructure) in LaTeX?

I would like to write something in LaTeX, where I need nested lists. It should be displayed like this: segment = [ [ [0,1,0],[1,1,1],[0,1,0] ] [ [1,1,1],[1,1,1],[1,1,1] ] ...
2
votes
1answer
3k views

How to generate LaTeX documents with Perl

I have to generate Software Requirement Specification documents in LaTeX. I have to use Perl to accomplish this. The documents consist of tables, lists, pictures, TOC, table of figures, headings and ...
3
votes
2answers
416 views

binary representation of an integer

Is there a way to get a binary string of an integer calculated by e.g., \pgfmathparse{pow(2,3)} \pgfmathresult such that later on I can use the string digits in a foreach loop like .. if it is '1' do ...
21
votes
2answers
668 views

Which is better: a dimension or a macro?

When messing around with TikZ/PGF then I frequently find myself wanting to store a length for later use. By "length" here, I mean the word in its non-TeX meaning. As I'm doing stuff in TikZ/PGF then ...
2
votes
1answer
1k views

How to pass a \def parameter to an inner command (StrSubstitute)?

I'm attempting to create 2 macros to simulate an array list as in Java for example. I'm using xstring StrSubstitute for this purpose, but I'm having a problem. Below is the code, it's a bit long as it ...