tikzfigure が方程式内にある場合、それを右端に揃えるにはどうすればよいですか?

tikzfigure が方程式内にある場合、それを右端に揃えるにはどうすればよいですか?

私の主な目標は、tikzfigure の左端にタグを配置することです。tikzfigure方程式の内側を定義すると、タグと衝突する中央に配置されます。右側にスペースがあるので、tikzfigure を右側に移動してタグとの衝突を防ぐにはどうすればよいですか。2 列で作業していることに注意してください。

texコード(元のコードはhttps://tex.stackexchange.com/a/661116/127048

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{lipsum}
\usepackage{amsmath}
\makeatletter
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos
\makeatother
\usepackage{tikz-cd}
\usetikzlibrary{positioning}
\begin{document}
\setcounter{page}{15}
\begingroup\leqnos
\lipsum[1][1-3]
\begin{equation}
  \begin{tikzcd}
      B\times_A
  \end{tikzcd}~\tag{a}
\end{equation}

\begin{equation}
  \begin{tikzpicture}[baseline=(current bounding box.center),compute/.style={draw,thick,font=\sffamily,
          append after command={
              (\tikzlastnode.south west) edge[double=gray!50,double distance=3pt,
              line cap=rect,
              shorten >=-2pt,shorten <=-2pt]
              (\tikzlastnode.south east)}}]
      \node[compute] (n1) {Node};
      \node[compute,right=2cm of n1, yshift=11mm] (n2) {More text};
      \node[compute,right=2.2cm of n2] (n3) {More};
      \node[compute,below=2cm of n2] (n4) {text};
      \draw[thick,-stealth] (n1) -- (n2) -- (n3) -- (n4);
  \end{tikzpicture}~\tag{b}
\end{equation}
  \endgroup
\end{document}

出力:

ここに画像の説明を入力してください

ここで、tikz 図が右にシフトすると、タグとの衝突が防止されます。

関連している:複数の tikz 図の左端に (a) (b) 記号を配置するにはどうすればよいですか?

答え1

画像の幅が広すぎて、1列の幅に収まりません。画像を1列に配置する必要がある場合は、

  • フォントサイズを または\smallに縮小する\footnotesie
  • 複数行のテキストを許可しながらノードの幅を狭める、
  • モード間の水平距離を短縮する、

できることは多くありません。前述のことをどのように実装できるかの例は次のとおりです。

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{lipsum}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\usepackage{amsmath}
\makeatletter
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos
\makeatother
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
\lipsum[1][1-3]

\begingroup\leqnos
\begin{equation}
   \begin{tikzcd}
       B\times_A
   \end{tikzcd}~\tag{a}
\end{equation}

\begin{equation}
    \begin{tikzpicture}[baseline=(current bounding box.center),
 node distance = 13mm,
compute/.style = {draw, thick, font=\small\sffamily, align=center,
                  append after command={\pgfextra{\let\LN\tikzlastnode}
                    (\LN.south west) edge[double=gray!50,double distance=3pt,
                                          line cap=rect,
                                          shorten >=-2pt,shorten <=-2pt]
                    (\LN.south east)}},
                        ]
    \node[compute] (n1) {Node};
    \node[compute,right=of n1] (n2) {More text};
    \node[compute,right=of n2] (n3) {More text text\\ text text text};
    \node[compute,below=of n2] (n4) {text};
    \draw[thick,draw, -Stealth, shorten > = 3pt, shorten < = 3pt]
        (n1) edge (n2)
        (n2) edge (n3)
        (n3) to (n4);
   \end{tikzpicture}~\tag{b}
\end{equation}
   \endgroup
\lipsum
\end{document}

ここに画像の説明を入力してください

補遺: コメントは以下のとおりです:

  • あなたのアプローチでは、あなたが望むものを得ることはできない
  • 1 つの方法は、左側に「参照不可」タグがあり、右側に中央揃えまたは左揃えで画像やその他のテキストがある新しい環境を定義することです。
  • sucn コマンドの例は次のようになります。
\usepackage{tabularray}

\newcommand\LST[3]{
    \begin{center}
    \begin{tblr}{colspec={@{} Q[c, font=\bfseries] X[#1] @{}} }
    #2  &   #3  
    \end{tblr}
    \end{center}}
  • compute上記の定義を使用する場合、ノード スタイルを少し再定義する必要があります。
compute/.style = {draw, thick, font=\small\sffamily, align=center,
                  append after command={\pgfextra{\let\LN\tikzlastnode}
                    ([xshift=-2pt] \LN.south west) 
                        edge[double=gray!50,double distance=3pt,
                                          line cap=rect]
                    ([xshift=+2pt] \LN.south east)}},
                        ]
  • 前述の使用例は次のとおりです。
\documentclass[journal,compsoc]{IEEEtran}
\usepackage{tabularray}
\newcommand\LST[3]{
    \begin{center}
    \begin{tblr}{colspec={@{} Q[c, font=\bfseries] X[#1] @{}} }
    #2  &   #3  
    \end{tblr}
    \end{center}}
\usepackage{caption}
\usepackage[export]{adjustbox}
\usepackage[label font=bf, labelformat=simple]{subfig}
\usepackage{lipsum}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
\lipsum[1][1-3]
\LST{c}{(a)}{$B\times_A$}
\LST{r}{(b)}{%
\begin{tikzpicture}[baseline=(current bounding box.center),
 node distance = 12mm,
compute/.style = {draw, thick, font=\small\sffamily, align=center,
                  append after command={\pgfextra{\let\LN\tikzlastnode}
                    ([xshift=-2pt] \LN.south west) 
                        edge[double=gray!50,double distance=3pt,
                                          line cap=rect]
                    ([xshift=+2pt] \LN.south east)}},
                        ]
    \node[compute] (n1) {Node};
    \node[compute,right=of n1] (n2) {More text};
    \node[compute,right=of n2] (n3) {More text text\\ text text text};
    \node[compute,below=of n2] (n4) {text};
    \draw[thick,draw, -Stealth, shorten > = 3pt, shorten < = 3pt]
        (n1) edge (n2)
        (n2) edge (n3)
        (n3) to (n4);
   \end{tikzpicture}%
        } 
\lipsum
\end{document}

申し訳ありませんが、(github) サーバー エラーのため、上記の MWE で作成した画像をアップロードできません。

答え2

「タグ (b)」とフローチャートの間にもっとスペースが必要なのだと思います。しかし、MWE に問題はありません。ページ余白の設定が原因かもしれません。以下の添付ファイルを参照してください。 ここに画像の説明を入力してください

もし私の推測が間違っていたら、何が欲しいのかもっと詳しくコメントしてください。

関連情報