Math & ScienceHelp: Creating Pascal-esque triangle (different structure and numbers) with TikZ for academic paper

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Help: Creating Pascal-esque triangle (different structure and numbers) with TikZ for academic paper

Post by Stefan Kottwitz »

Regarding the error in \usepackage{pgfplots,lua-visual-debug}}, with one } too many, that's interesting. Because it's not in the code, where we have \usepackage{pgfplots,luacode}. Could look like a typo or auto-completion-error, but you would see that in the code.

Especially as it appears in line 1 (l.1) it looks like it's from another document, like one included by \input, or in some file that's used. It can happen when there are other files in the same folder/directory, that are accidentally loaded. Sometimes people have files in the same folder but named them accidentally like a LaTeX package, or have some downloaded file with an issue.

Perhaps post the log file here, as attachment? I know you may nott need it, but it would be interesting to find out why it happens. It could be an issue another time, too.

By the way, lua-visual-debug is pretty nice. I don't really have a use for it, but at some point it may help if spacing or complex formula contruction would be strange. Quick example from my LaTeX Cookbook:

Code: Select all

\documentclass[paper=a4,oneside,fontsize=11pt,
  parskip=full]{scrartcl}
\usepackage{lua-visual-debug}
\pagestyle{empty}
\begin{document}
\section{Some maths}
Let's look at an integral approximation of a function
$f(x)$ as a sum with weights $w_i$:
\begin{equation}
  \int_a^b f(x)\,\mathrm{d}x \approx (b-a)
  \sum_{i=0}^n w_i f(x_i)
\end{equation}
\end{document}
boxes.jpg
boxes.jpg (118.97 KiB) Viewed 2686 times
Also, btw. if something strange seems to happen with TeX on your local machine, you could easily use any code box here in the forum, copy your .tex code in, and run the online compiler in the forum. Then you see what happens with a current TeX Live 2025, and if there's an issue with local files on your computer instead or really with TeX/LaTeX.

Stefan
LaTeX.org admin

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

spe420
Posts: 9
Joined: Tue Jun 03, 2025 8:52 am

Re: Help: Creating Pascal-esque triangle (different structure and numbers) with TikZ for academic paper

Post by spe420 »

I'm unsure what the error was, but for whatever reason, it resolved when I restarted the program. Very strange. Perhaps, as you say, it inadvertently loaded another file by mistake.
spe420
Posts: 9
Joined: Tue Jun 03, 2025 8:52 am

Re: Help: Creating Pascal-esque triangle (different structure and numbers) with TikZ for academic paper

Post by spe420 »

So, I was talking with a colleague about this, and as I am finding it difficult to make time for working on this between other things (life getting in the way, etc.) he suggested I submit my query to grok. After some time explaining what I was trying to do, it spit out this code:

Code: Select all

\documentclass{article} 
\usepackage{tikz,amsmath} 

\begin{document}
\begin{tikzpicture}[scale=0.7] 
\foreach \row [evaluate=\row as \introw using int(floor(\row))] in {0,0.5,...,3} { 
\pgfmathsetmacro{\spacing}{ifthenelse(int(\introw), 
(2*\introw-2)/(4*\introw), (2*\introw+2)/(4*\introw))} 
\node[anchor=east] at (-1,-\row*1.5) {\row}; 
\foreach \col in {0,...,\introw} { \def\collabel{\ifodd\col b\else a\fi} 
\pgfmathsetmacro{\entry}{ifthenelse(\row<1, 1, int(5*\col+1))} 
\node at (\col*1.5*\spacing,-\row*1.5) 
{\(\entry\) (\collabel)}; } } 

\end{tikzpicture}
\end{document}
I still haven't made enough headway in my various books (yours, TeXbook, TeX By Topic, and Unlocking LaTeX Graphics) to really grasp where, but the output is giving me 100 errors. It says something about division by 0 occurring somewhere. I am somewhat out of my depth as to whether it is even doing what I was getting at. Any thoughts? I noticed immediately that the "ifthenelse" operator was not begun with a backslash, and tried changing that, but clearly wasn't the issue (if even an issue). Would be appreciative of any help.
Post Reply