I have learned from the following questions:
- "For loop" in newcommand
- Use pgffor to define a new command?
- \foreach with \newcommand how to use them together?
I was trying to pass an ancestries list as an array with a new command or a definition or a new command with a definition as an array to the same new command or the same definition.
Here is the small code:
\documentclass{standalone}
\usepackage{graphicx}
\usepackage{pgffor}
\usepackage{svg}
\usepackage[all]{genealogytree}
\newlength{\mypx}
\setlength{\mypx}{0.013889in}
\newcommand\Ancestries[1]
{
\def\ancestrieslist{#1}
\foreach \ancestry in \ancestrieslist
{
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/\ancestry.svg}\par
}
}
\begin{document}
\linespread{1.5}
\begin{tikzpicture}
\genealogytree
{
parent
{
g[id = 01, male, box = {title = Self}]
{
\textbf{Ancestries}\\
\Ancestries{argentina, brazil, italy, portugal, spain}\\
}
}
}
\end{tikzpicture}
\end{document}
I also tried two other ways:
\newcommand{\Ancestries}[1]
{
\foreach \x in {#1}
{%
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/\x.svg}\par%
}
}
\def\Ancestries#1
{%
\foreach \x in {#1}
{%
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/\x.svg}\par%
}
}
The result should look like:
\textbf{Ancestries}\\
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/argentina.svg}
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/brazil.svg}
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/italy.svg}
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/portugal.svg}
\includesvg[width={10\mypx}]{assets/images/flags/twemoji/spain.svg}
Small log here:
No file minha-genealogia-completa-01.aux.
(/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd) (|'inkscape' -V ) (./svg-inkscape/argentina_svg-tex.pdf_tex) (./svg-inkscape/brazil_svg-tex.pdf_tex) (./svg-inkscape/italy_svg-tex.pdf_tex) (./svg-inkscape/portugal_svg-tex.pdf_tex) (./svg-inkscape/spain_svg-tex.pdf_tex)
/home/Ooo/minha-genealogia-completa-01.tex:113: LaTeX Error: There's no line here to end.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.113 ^^I^^I}
No pages of output.
assets/images/flags/twemoji/folder. – Skillmon Oct 30 '23 at 15:36\parat the end of each of your entries you can't put a\\after your\Ancestries, because then you'd do\par\\and that throws the error in your question. Just remove the\\and you should be good to go. – Skillmon Nov 01 '23 at 18:37