來自 \subfigimg 巨集的標籤隱藏在 xepersian 中

來自 \subfigimg 巨集的標籤隱藏在 xepersian 中

當在 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}

編輯新增

關鍵是,with xepersian{A}\llap{B}意思A是放在 上面B\rlap執行正常的文字流方向。

我需要類似的東西,可以使用語句在圖像的左上角 (TL)、右上角 (TR)、左下角 (BL) 或右下角 (BR) 中選擇文字if。另外,我在圖像上添加了文本bidicontour,這使得文本更易於閱讀。

這是右上角的位置:

圖像上的文字 RTL

特寫:

特寫

微量元素

\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 軸)反射的「旋向性」的練習。很有意思。

相關內容