1

Thank Tex community & Stack Exchange. Hi friends,

With supporting of Mr @marmot, i can create "variable Array" in file myarrays.tex. Link topic: Global variable Array

Now i want call/insert some variable of myarrays.tex for tcolorbox of templateA.tex

MWE by Mr Marmot:

 \documentclass[a4paper,twoside,12pt]{article}
\usepackage{tcolorbox}
\usepackage{filecontents}
\begin{filecontents*}{myarrays.tex}
\def\ArrayNames{{"koala","duck","marmot","penguin","bear"}}
\def\ArrayColors{{"gray","yellow","blue","red","brown","green!30!white","blue!75!black"}}
\end{filecontents*}
\usepackage{pgffor}
\usepackage{xcolor}
\begin{document}
\input{myarrays.tex}
\pgfkeys{/pgf/declare function={mymap(\x)=int(mod(1+\x*\x,4));}}
\begin{enumerate}
\foreach \X in \ArrayNames
{\foreach \Y [count=\Z starting from 0]in \X 
{\pgfmathsetmacro{\mycolor}{\ArrayColors[mymap(\Z)]}
\pgfmathsetmacro{\myname}{\ArrayNames[\Z]}
\item \textcolor{\mycolor}{\myname}}}
\end{enumerate}
\input{myarrays.tex} \pgfmathsetmacro{\myname}{\ArrayNames[3]} \myname

\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,title=\color{white}\textbf{My Heading}]
    This is a \textbf{tcolorbox}.
    \tcblower
    Here. In the box
    \end{tcolorbox}
    \end{document}

Now, Please guide me. I want to change in tcolorbox by using of Array variable:

1/ Title = Arrayname (2) = \color{white}\textbf{Marmot} (old Title = My Heading)

2/ colback = \ArrayColors (5) = "green!30!white"

3/ colframe = \ArrayColors (6) = "blue!75!black"

Thank in advance.

1 Answer 1

2

You already have that loop, so you just need to include the variables.

Btw: As your file only contains \defs it is pointless to include it twice.

boxes

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{tcolorbox}
\usepackage{filecontents}
\begin{filecontents*}{myarrays.tex}
\def\ArrayNames{{"koala","duck","marmot","penguin","bear"}}
\def\ArrayColors{{"gray","yellow","blue","red","brown","green!30!white","blue!75!black"}}
\end{filecontents*}
\usepackage{pgffor}
\usepackage{xcolor}
\begin{document}
\input{myarrays.tex}
\pgfkeys{/pgf/declare function={mymap(\x)=int(mod(1+\x*\x,4));}}
\begin{enumerate}
\foreach \X in \ArrayNames
{\foreach \Y [count=\Z starting from 0]in \X 
{\pgfmathsetmacro{\mycolor}{\ArrayColors[mymap(\Z)]}
\pgfmathsetmacro{\myname}{\ArrayNames[\Z]}
\item \textcolor{\mycolor}{\myname}}}
\end{enumerate}

\foreach \X in \ArrayNames
{\foreach \Y [count=\Z starting from 0]in \X 
{\pgfmathsetmacro{\mycolback}{\ArrayColors[5]}
\pgfmathsetmacro{\mycolframe}{\ArrayColors[6]}
\pgfmathsetmacro{\myname}{\ArrayNames[\Z]}
\begin{tcolorbox}[colback=\mycolback,colframe=\mycolframe,title=\color{white}\textbf{\myname}]
    This is a \textbf{tcolorbox}.
    \tcblower
    Here. In the box
\end{tcolorbox}
}}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .