xepersian で隠された \subfigimg マクロのラベル

xepersian で隠された \subfigimg マクロのラベル

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

下にあります。

対称性のため、右と左の重なり、および画像とテキストの望ましい結果につながる組み合わせは、おそらく 6 つ (正しい順序で実行) になるはずです。

このバージョンでは、最初にラベルを配置し、次に両側に同じ余白を設けて画像に重ね合わせ、ラベルを画像の左側に配置します。

上部のテキスト

ムウェ

\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}ことです。は、通常のテキストフロー方向を実行します。AB\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 軸)反射の「利き手」に関する演習です。非常に興味深いです。

関連情報