Pre topic: Display Box A or Box B if then condition
Now i use newcommand with one varialbe
Minimal coding:
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.tex}
No,TextX,TextY,TextZ,TextW
1,x1,y1,z1,w1
2,,y2,z2,w2
3,,y3,w3,
4,,,,w4
5,x5,y5,,
6,,y6,z6,w6
7,x7,y7,z7,w7
8,x8,,z8,w8
9,x9,,z9,w9
10,x10,y10,z10,w10
11,,y11,z11,w11
12,,y12,,
13,,,z13,w13
14,x14,,z14,w14
15,x15,y15,,w15
16,x16,y16,z16,w16
\end{filecontents*}
\documentclass{article}
\usepackage[a4paper,landscape]{geometry}
\usepackage{datatool}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbuselibrary{poster}
\usepackage{enumitem, setspace}
\tcbset{colframe=blue!75!black,colback=white}
\DTLloaddb{file}{\jobname.tex}
\newcommand{\selectONE}[1]{%
\if\relax#1\relax
\selectA % 00
\else
\selectB % 01
\fi
}
\newcommand{\selectONEA}{%
%\posterbox[colframe=red,width=5cm,height=5cm]{name=A,column=1}{%
\includegraphics[height=3cm]{example-image-a}
\begin{enumerate}[wide, leftmargin =-1em, rightmargin=-1em]
\item A \TextX
\end{enumerate}
%}%
}
\newcommand{\selectONEB}{%
%Box B
%\posterbox[colframe=blue,width=5cm,height=5cm]{name=B,column=1,xshift=5.0cm,yshift=0.0cm}{%
\begin{enumerate}
\item B \TextY
\item B \TextY
\end{enumerate}
\includegraphics[height=2cm]{example-image-b}
%}%
}
\begin{document}
\DTLforeach*{file}% Database
{\No=No,\TextX=TextX,\TextY=TextY,\TextZ=TextZ,\TextW=TextW}
{%
\begin{tcbposter}[
poster = {
columns=1,
rows=1,
spacing=3mm,
height=14cm,
width=12cm,
},
]
\posterbox[colframe=green,width=5cm,height=5cm]{name=C,column=1,xshift=2.0cm,yshift=-1.0cm}{%
\selectONE{\TextX}
}
\posterbox[colframe=green,width=5cm,height=5cm]{name=C,column=1,xshift=8.0cm,yshift=-7.0cm}{%
\selectONE{\TextY}
}
\end{tcbposter}
\newpage
}
\end{document}
In this code, overleaf appear error notification: undefined control sequence
Thank in advance
ONE
in\selectA
and\selectB
, it needs to be\newcommand{\selectONE}[1]{% \if\relax#1\relax \selectONEA % 00 \else \selectONEB % 01 \fi }
instead of\newcommand{\selectONE}[1]{% \if\relax#1\relax \selectA % 00 \else \selectB % 01 \fi }
\begin{filecontents*}{\jobname.tex}
is a bad idea. It may work on overleaf but in a local system it would either not work or it would be a disaster if it did. So don't get into the habitude to use this syntax.\jobname.tex
. In local systems\jobname.tex
usually denotes the name of the main .tex-file of the source-code of the document which LaTeX is processing. E.g., if on a local system the source of my document is saved asmain.tex
and is compiled via the command-linepdflatex main.tex
, then\jobname
will yield the sequencemain
. Trying to overwritemain.tex
will not be a good idea. Your question reminds me of this question.