在 xepersian 环境中使用“\subfigimg”宏时,每幅图像上的标签丢失:
\documentclass[preview]{standalone}
\usepackage{mwe}
\usepackage[table]{xcolor}
\usepackage{xepersian}
\settextfont{XB Zar}
\newcommand{\subfigimg}[3][,]{%
\setbox1=\hbox{\includegraphics[#1]{#3}}% Store image in box
\leavevmode\rlap{\usebox1}% Print image
\rlap{\raisebox{\dimexpr\ht1-1\baselineskip}{\textbf{\color{red}#2}}}% Print label
\phantom{\usebox1}% Insert appropriate spcing
}
\begin{document}
\begin{figure}[htp]
\centering
\begin{tabular}{@{}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{}}
\subfigimg[width=\linewidth]{الف}{example-image-a} &
\subfigimg[width=\linewidth]{ب}{example-image-b} &
\subfigimg[width=\linewidth]{پ}{example-image-c} \\
\end{tabular}
\end{figure}
\end{document}
答案1
它们在下面。
由于对称性,大概有六种组合(按照正确的顺序进行)才能达到所需的结果,即左右重叠以及图像和文本。
此版本先放置标签,然后将其重叠到图像上,两边的边距相同,标签位于图像的左侧:
平均能量损失
\documentclass{article}%[preview]{standalone}
\usepackage{mwe}
\usepackage[table]{xcolor}
\usepackage{xepersian}
\settextfont{XB Niloofar}%Zar}
\newcommand{\subfigimg}[3][,]{%
\setbox1=\hbox{\includegraphics[#1]{#3}}% Store image in box
\leavevmode%{\usebox1}% Print image
{\phantom{\usebox1}}% Insert appropriate spcing
\llap{\raisebox{\dimexpr\ht1-1\baselineskip}{\textbf{\color{red}#2}}}% Print label
\llap{\usebox1}
% \phantom{\usebox1}% Insert appropriate spcing
}
\begin{document}
\large
\begin{figure}[htp]
\centering
\begin{tabular}{@{}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{}}
\subfigimg[width=\linewidth]{الف}{example-image-a} &
\subfigimg[width=\linewidth]{ب}{example-image-b} &
\subfigimg[width=\linewidth]{پ}{example-image-c} \\
\end{tabular}
\end{figure}
\end{document}
编辑添加
关键是,使用xepersian
,这{A}\llap{B}
意味着A
放在 之上B
。\rlap
按照正常的文本流方向。
if
我需要类似的东西,使用语句可选择将文本放在图像的左上角 (TL)、右上角 (TR)、左下角 (BL) 或右下角 (BR) 。此外,对于图像上的文本,我添加了bidicontour
,这使文本更易于阅读。
这是右上角的位置:
特写:
平均能量损失
\documentclass{article}
\usepackage{graphicx}
\usepackage[outline]{bidicontour}%before xepersian
\usepackage[table]{xcolor}
\usepackage{xepersian}
\settextfont{XB Niloofar}
\newcommand\imagea{}
\newcommand\texta{}
\newif\ifcaptionBR
\newif\ifcaptionTR
\newif\ifcaptionBL
\newif\ifcaptionTL
\newcommand\capinit{%
\captionBRfalse
\captionTRfalse
\captionBLfalse
\captionTLfalse
}
\newcommand\capimage[2]{%1=image,2=text,(3=location: global)
\ifcaptionBR%
{#2}\kern-\wd2{#1}
\fi%
\ifcaptionTR%
{\raisebox{\dimexpr\ht1-\baselineskip}{#2}}\kern-\wd2{#1}
\fi%
\ifcaptionBL%
{\phantom{#1}}\llap{#2}\llap{#1}
\fi%
\ifcaptionTL%
{\phantom{#1}}\llap{\raisebox{\dimexpr\ht1-\baselineskip}{#2}}\llap{#1}
\fi%
}
\newcommand\subimg[4]{% 1=width,2=image,3=text, 4=text location command
\renewcommand\imagea{\includegraphics[width=#1]{#2}}
\renewcommand\texta{{\textcolor{red}{\textbf{\bidicontour{yellow}{#3}}}}}
\setbox1=\hbox{\imagea}
\setbox2=\hbox{\texta}
\capinit
#4
\capimage{\imagea}{\texta}
}
\bidicontourlength{0.8pt}
\begin{document}
%
%\subimg{0.30\linewidth}{example-image-a}{الف}{\captionTLtrue}
%
%
%\subimg{0.30\linewidth}{example-image-a}{الف}{\captionBLtrue}
%
%
%\subimg{0.30\linewidth}{example-image-a}{الف}{\captionTRtrue}
%
%
%
%
%\subimg{0.30\linewidth}{example-image-a}{الف}{\captionBRtrue}
\begin{figure}[htp]
\centering
\begin{tabular}{@{}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{\hspace{1mm}}p{0.33\linewidth}@{}}
\subimg{0.98\linewidth}{example-image-a}{الف}{\captionTRtrue} &
\subimg{0.98\linewidth}{example-image-b}{ب}{\captionTRtrue} &
\subimg{0.98\linewidth}{example-image-c}{پ}{\captionTRtrue} \\
\end{tabular}
\end{figure}
\end{document}
这是关于对称群和(2 轴)反射的“手性”的练习。非常有趣。