新年快乐,
上一个主题:旋转海报框中的文本
现在,我想使用新命令语句/宏插入图像:
位置视图:在BOX下方=5mm处
如果否 = A/B/C => 查看图片示例 A/B/C
否则,此位置显示为空白或无任何内容
提前感谢,2020 年新年快乐
我的最低限度的编码:
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.tex}
No,TextX,TextY,TextZ,TextW
1,x1,y1,z1,w1
B,,y2,z2,w2
3,,y3,w3,
A,,,,w4
5,x5,y5,,
6,,y6,z6,w6
A,x7,y7,z7,w7
8,x8,,z8,w8
9,x9,,z9,w9
C,x10,y10,z10,w10
11,,y11,z11,w11
A,,y12,,
13,,,z13,w13
B,x14,,z14,w14
15,x15,y15,,w15
C,x16,y16,z16,w16
\end{filecontents*}
\documentclass{article}
\usepackage[a4paper,landscape]{geometry}
\usepackage{datatool}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbuselibrary{poster}
\usetikzlibrary{positioning}
\usepackage{lipsum}
\usepackage{enumitem, setspace}
\tcbset{colframe=blue!75!black,colback=white}
\DTLloaddb{file}{\jobname.tex}
\newcommand{\No}[1]{%
\if
\includegraphics[height=1cm]{example-image-a}
\else
\includegraphics[height=1cm]{example-image-b}
\fi
}
\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 = red,
width=6cm, height= 6cm
]{name=BOX,column=1}{insert image with condition}
\node[font=\sffamily\Large,rotate=0,below=5mm of TCBPOSTER@BOX] {\No};
\end{tcbposter}
\newpage
}
\end{document}
答案1
新年快乐!
\RequirePackage{filecontents}
\begin{filecontents*}{pleasedonotusefilenamehere.tex}
No,TextX,TextY,TextZ,TextW
1,x1,y1,z1,w1
B,,y2,z2,w2
3,,y3,w3,
A,,,,w4
5,x5,y5,,
6,,y6,z6,w6
A,x7,y7,z7,w7
8,x8,,z8,w8
9,x9,,z9,w9
C,x10,y10,z10,w10
11,,y11,z11,w11
A,,y12,,
13,,,z13,w13
B,x14,,z14,w14
15,x15,y15,,w15
C,x16,y16,z16,w16
\end{filecontents*}
\documentclass{article}
\usepackage[a4paper,landscape]{geometry}
\usepackage{datatool}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbuselibrary{poster}
\usetikzlibrary{positioning}
\usepackage{lipsum}
\usepackage{enumitem, setspace}
\tcbset{colframe=blue!75!black,colback=white}
\DTLloaddb{file}{pleasedonotusefilenamehere.tex}
\newcommand{\NoCond}[1]{%
\begingroup
\edef\myA{A}%
\edef\myB{B}%
\edef\myC{C}%
\ifx#1\myA
\includegraphics[height=1cm]{example-image-a}
\else
\ifx#1\myB
\includegraphics[height=1cm]{example-image-b}
\else
\ifx#1\myC
\includegraphics[height=1cm]{example-image-c}
\else
\fi
\fi
\fi
\endgroup
}
\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 = red,
width=6cm, height= 6cm
]{name=BOX,column=1}{\NoCond{\No}}
\node[font=\sffamily\Large,rotate=0,below=5mm of TCBPOSTER@BOX] {\No};
\end{tcbposter}
\newpage
}
\end{document}
PS 请不要使用\begin{filecontents*}{\jobname.tex}
,如果他们的主文件不被覆盖,少数剩余的非 overleaf 用户将不胜感激。