{programming} is about how (La)TeX can be used as a programming language.
17
votes
3answers
658 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, ...
16
votes
2answers
186 views
Difficulty with macro expansion (updated)
Update. I have another problem that is so closely related to this one that I decided not to raise it as a new question, but instead to edit this one. Although Heiko's answer has explained how to fix ...
9
votes
3answers
423 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 ...
0
votes
0answers
26 views
How can i go to a new designed Form in C#? [migrated]
im new in C# and also in this website ;)
I have a form and there is a NexT BUtton in it,i want to go to another form by clicking the Next Buttun,,,and i want to have some objects like text box or ...
39
votes
5answers
1k views
How to print the permutation of {s,u,v,a,t} with LaTeX?
I want to use LaTeX to print the permutation of a set {s,u,v,a,t}. The output looks like the following.
suvat
suvta
suavt
suatv
...
There are 120 rows in total that must be generated on the fly.
...
7
votes
2answers
111 views
How to parse optional arguments without keyval?
The current implementation only supports rounding with the specified digits in the optional arguments.
\documentclass{beamer}
\usepackage{multido}
\usepackage{pstricks}
\usepackage[nomessages]{fp}
% ...
2
votes
0answers
36 views
How to throw an error and abort the compilation for the following scenario? [duplicate]
Objectives:
I want to throw exceptions (or error messages) when the following illegal code is invoked.
\const[c,any]{temp}{\f[\i]}
\const[others]{temp}{\f[\i]}
Minimal Working Example:
I cannot ...
1
vote
1answer
68 views
What causes this error? [closed]
After seeing Herbert's answer, apparently this problem should not occur if I realized the first row of the following code should be \documentclass{beamer}. Problems often come from not knowing what I ...
4
votes
1answer
42 views
How to implement a constant declarating macro to behave differently in preamble and pspicture?
The example below is extremely trivial just to illustrate the problem in the simplest way.
\documentclass{beamer}
\usepackage[nomessages]{fp}
% constants declarator
\def\LoadConstants{}% to load ...
6
votes
2answers
134 views
How to make the following recursive macro work?
For positive values less than 3 the following MWE works.
\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor
\psset{showpoints=true}
\def\Triangle#1{%
\ifnum#1=1\relax
...
-1
votes
0answers
61 views
Structure arrays, files in C [closed]
I'm having some issues with the output of this program.
The logic seems to be okay, but whenever I compile/run it I get an (11db) in the output section (I use Xcode).
It says "build succeeded" ...
10
votes
1answer
211 views
ConTeXt (core) command definitions: what do \installcorenamespace, \?? and \installcommandhandler, do?
I have the very strong impression that there is a Current and Standard way to define new (core) commands in ConTeXt; see, for example, this quote from an e-mail by Wolfgang.
Many of the \define... ...
4
votes
2answers
62 views
Can't generate a tikz matrix, using expl3
Suppose, I want to generate a matrix of nodes:
\documentclass{article}
\usepackage{expl3}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\matrix
[
row ...
7
votes
2answers
161 views
How can I store variables in lists and make use of them?
This question is clearly related to How can I store variables and iterate over them?.
I'm sorry to ask such a close one, but I really don't understand the answer in plain TeX by David Carlisle.
...
6
votes
3answers
199 views
How to use data structures in TikZ?
I created a foreach statement, using expl3 and TikZ/pgf:
\documentclass{article}
\usepackage{tikz}
\setlength{\parindent}{0cm}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \Counter #1 \Stopper { ...
3
votes
1answer
38 views
How to use a macro inside \tl_set:Nx
This code works:
\documentclass{article}
\usepackage{expl3}
\usepackage{color}
\setlength\parindent{0pt}
\begin{document}
\ExplSyntaxOn
\tl_new:N \_text
\tl_set:Nn \text {1}
\tl_set:Nx \text ...
17
votes
2answers
276 views
How to generate a table of trigonometric functions that can be broken across pages?
Consider the following screenshot.
The features I want to have are:
I can shrink the page size and the table is allowed to break across pages.
The background of odd rows must be different from ...
20
votes
1answer
248 views
Bad interaction between fontspec and some lua code that performs string-related search and replace operations
I'm in the process of readying a LuaLaTeX package for "official" release to the CTAN, but I need to squash a few remaining bugs first. The bug described in this question concerns incorrect behavior of ...
1
vote
0answers
83 views
Compare two comma separated lists
Hi I would like to compare two comma separated lists.
\documentclass[a4paper]{article}
\usepackage{comment}
\usepackage{ifthen}
\usepackage{xargs}
\usepackage{xkeyval}
\usepackage{xfor}
...
9
votes
3answers
108 views
How to use \toks with \foreach
I would like to use \foreach to replace the next code :
\def\x{0}
\edef\y{\x}
\xdef\z{(b\y)}
\def\x{1}
\edef\y{\x}
\xdef\w{\z(b\y)}
\def\x{2}
\edef\y{\x}
\xdef\z{\w(b\y)}
...
8
votes
1answer
130 views
Using \toks registers
I was reading this tutorial for TeX programming:
http://pgfplots.sourceforge.net/TeX-programming-notes.pdf
recommended in the 2-nd answer here: Where do I start LaTeX programming?
It says:
...
4
votes
1answer
216 views
Is it possible to make LaTeX read the sectioning in reverse direction?
I want to make a note (for internal use only) while I am reading a book. For the sake of convenience, I want to put a note about the current topic I am reading on the first page of the PDF output to ...
11
votes
1answer
130 views
Loading latex from tex
I decided venture into the very basics of the world of TeX and LaTeX. I have been playing around with tex, pdftex and latex and after paying close attention to the binaries and not being able to ...
3
votes
0answers
88 views
Optimizing tikz code for less redundancies
I don't use tikz very often. When I do, I'm usually pretty happy with the result (and with how useful that manual is). But I always think the code I produced to get there could be optimized, as in the ...
21
votes
2answers
798 views
What does \z@ do?
in parcolumns it has \z@ all over the space. I don't see it define it anywhere so I assume it is some internal command or something? I can't really make heads or tails of it though and I can't really ...
3
votes
1answer
39 views
How to select all occurrences of a specified word in a string and append another word to each of them?
When using infix-RPN package, we can use \infixtoRPN to convert infix expression to RPN expression. The output of the conversion can be retrieved by invoking \RPN.
\infixtoRPN{cos(x)+sin(x)}, for ...
14
votes
2answers
272 views
LaTeX3: How to get reliable control over the level of expansion?
Say you want to write LaTeX3 code that manages user data. Sometimes you want to process that data, but other times you just want to store it, move it around and return it unchanged (when developing a ...
10
votes
3answers
157 views
Gobbling an argument if it starts with #
My problem comes from pandoc and markdown, but it is not directly related with these tools, but instead with "customizing" the resulting pdf via some tex macro programming, so I think it is on topic.
...
23
votes
3answers
486 views
Saving a 100 tokens worth, is it worth it?
The LaTeX kernel defines a number of tokens that are used throughout the LaTeX source and the standard LaTeX classes. For example:
\def\hb@xt@{\hbox to}
This particular one is commented as:
...
13
votes
5answers
722 views
How can I store variables and iterate over them?
I want to know how I can store variables so I can iterate over them.
Say we have this input in the document:
\inputcommandname{first input}
\inputcommandname{second input}
\inputcommandname{third ...
3
votes
2answers
114 views
Toggle visibility of solutions in LaTeX output for exams
So I have my own layout for my exams based on scrartcl and to prevent anomalies during some changes I want to have only one file per exam which holds both questions/excercises and solutions. Yet I ...
86
votes
5answers
8k 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). ...
22
votes
3answers
519 views
How to know whether or not we need \expandafter?
The following is quoted from Peter Grill's answer on question LaTeX dynamic macro definition.
The \expandafter is requried as the \newcommand needs to be dealt
with after the \csname.
As a ...
28
votes
4answers
1k views
A critique of TeX?
Is there any informative critique of TeX along one or all the lines below:
TeX, the typesetting engine (including its algorithms)
TeX, the typesetting language
TeX, the programming language
TeX, the ...
2
votes
2answers
786 views
How can I process an array using TikZ 2.00 syntax?
I use TikZ/PGF 2.00. In the CVS PGF manual pag. 563 we have
\def\myarray{{1,"two",2+1,"IV","cinq","sechs",sin(\i*5)*14}}
\foreach \i in {0,...,6}{\pgfmathparse{\myarray[\i]}\pgfmathresult, }
My ...
25
votes
2answers
745 views
What language is TeX implemented in?
I read on Wikipedia that the first version of TeX was written in SAIL. However, does anyone know what language later versions (i.e the current one) are implemented in?
7
votes
3answers
162 views
When to use or avoid grouping?
For writing my own TeX code, grouping (\begingroup, \endgroup) helps on automatically saving and restoring TeX "variables".
(La)TeX "variables" are either macros or registers. The registers can
...
15
votes
2answers
179 views
Macro Improvements
I am looking to simplify and improve on the code below:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{test.txt}
a an and the this by on of
\end{filecontents}
...
17
votes
2answers
211 views
Defining a dimension with or without @
If I am writing a TeX package (as one can find such on CTAN), there are following approaches to define a new dimension length that should be changeable by a user of that package.
Approach A: Define ...
11
votes
3answers
194 views
Getting the last token of a macro argument
It is easy to get the first token of a macro argument. Ignoring some irrelevant complications, you do something like this:
\def\firsttokof#1{\first(#1)}
\def\first(#1#2){#1}
It's equally easy to ...
10
votes
2answers
159 views
How to make the last word in a sequence the first?
I am looking for a macro that would take a string (better to say -- a sequence of words) and output the last word at the fist place before remaning part of the sequence. I want to put this macro into ...
1
vote
0answers
99 views
Writing simple LaTeX workspace [closed]
I have this project in which I need to write something like a workspace for LaTeX.
Basically I need to make split window. In one you would write the TeX code and in the other you would see the live ...
8
votes
2answers
956 views
How to break out of a loop
I have been trying to automate the production of stepped tables that contain conversion factors of all sorts. (See Protrusion of fractions in tabulars).
As part of this I have a rather convoluted ...
2
votes
0answers
61 views
How do I get my comma back (C++ lstlisting section) [duplicate]
Possible Duplicate:
Comma inside \texttt{} does’nt show up
I've been writing code in my book and just noticed that the comma has gone. I've been moving between machines so I don't know if ...
16
votes
2answers
516 views
Stripping the pt from a dimension
LaTeX defines in ltfssbas.dtx a macro called \strip@pt (at line [246]) which strips the pt part from a dimension returned by \the\dimension. The definition is shown as a minimal working example below:
...
14
votes
2answers
135 views
Get number of elements in enumerate
Suppose, I have the following code:
\documentclass{article}
\begin{document}
We have totally 7 columns, describing the user:
\begin{enumerate}
\item ID --- users.name
\item Forename --- ...
0
votes
0answers
25 views
modifying PrintDescribeMacro of doc.sty
I would like to redefine the command PrintDescribeMacroof doc.sty
in order to create a label that I can link to using hyperref.
However whenever I add a label to the command I get an error
...
6
votes
1answer
143 views
Programming with pgf arrays : how to create an array?
I am trying to do some automatic drawing in tikz. The point is I want to be able to provide the minimal quantity of information to my macro, and still have it work.
More precisely (but without ...
11
votes
1answer
862 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 ...
4
votes
2answers
76 views
How to write an environment wrapping document environment
I'm working on wrapping up some patterns used in my research group for creating posters. Since we're using beamer and beamerposter to make these, all documents go essentially like this:
...




