
blue
またはなどのオプションtext=blue
をノードに適用しようとした結果発生する問題を特定するのに協力してくれたSašoŽivanovićに感謝します。森木々には回転式改札口があり、回転式改札口パッケージ。
通常、TikZ ノードなどに色オプションを適用するとblue
、テキストであろうと数式であろうと、ノードの内容が色付きになります。
ただし、ノードに回転式改札口パッケージの場合、色付けは回転式改札口の前後の内容物にのみ影響します。回転式改札口自体は影響を受けません。
を使用するとtext=blue
、ターンスタイルより前のコンテンツのみが色付けされます。ターンスタイルもその後の内容も影響を受けません。
ただし、環境外ではtikzpicture
、回転式改札口は周囲のテキストや数式と同様に通常の色で表示されます。
例えば、
{\color{blue}
\[
p \leftrightarrow q \sststile{}{} p \rightarrow q
\]
}
\centering
TikZ/blue:
\tikz{\node [blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
TikZ/blue text:
\tikz{\node [text=blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
生産する
Sašo Živanović は、ここでの問題は回転式改札口に特有のものではなく、\sbox{}
同様の方法で使用されるあらゆるコンテンツに当てはまることを明らかにしました。たとえば、次のようになります。
\newsavebox\mybox
{\color{blue} This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.}
\tikz{\node[blue]{This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.};}
生産する
この質問これも私を導いてくれたサショ・ジヴァノヴィッチ氏に感謝しているが、関連があるようだ。
そこでの議論から推測すると、\sbox{}
オプションの前に が実行されるblue
か、text=blue
ノード コンテンツに適用されるため、ボックスが保存された時点でのアクティブな色は、ノードに適用されたオプションの影響を受けないことになります。
これは正しいですか? この効果は回避できますか? また、 がtext=blue
何か違うことをするのはなぜですか? の効果は\sbox{}
そのグループに限定されるべきではないですか? そうすれば、その内容が黒のままであっても、後続の内容は適切に色付けされるはずです。
MWE を完了する:
\documentclass{article}
\usepackage{turnstile,tikz}
\begin{document}
{\color{blue}
\[
p \leftrightarrow q \sststile{}{} p \rightarrow q
\]
}
\centering
TikZ/blue:
\tikz{\node [blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
TikZ/blue text:
\tikz{\node [text=blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
\newsavebox\mybox
{\color{blue} This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.}
\tikz{\node[blue]{This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.};}
\end{document}
答え1
これは、LaTeX が理解する現在の色を設定していない、pgf カラー サポートの失敗のようです。
\documentclass{article}
\usepackage{turnstile,tikz}
\makeatletter
\begin{document}
{\color{blue}
\[
p \leftrightarrow q \sststile{}{} p \rightarrow q
\]
}
\centering
TikZ/blue:
\tikz{\node [blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
TikZ/blue text:
\tikz{\node [text=blue] {$p \leftrightarrow q \sststile{}{} p \rightarrow q$}; }
\newsavebox\mybox
{\color{blue} \show\current@color This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.}
\tikz{\node[blue]{\show\current@color\show\pgf@strokecolor@global This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.};}
\edef\foo#1#2#3#4#5{#3}
\def\resetcurrentcolor{\edef\current@color{\expandafter\foo\pgf@strokecolor@global}}
\tikz{\node[blue]{\resetcurrentcolor This is in blue. \sbox{\mybox}{This is in a box.}\usebox{\mybox} This is in blue.};}
\end{document}
ログを生成する
> \current@color=macro:
->0 0 1 rg 0 0 1 RG.
l.21 {\color{blue} \show\current@color
This is in blue. \sbox{\mybox}{This i...
?
> \current@color=macro:
->0 g 0 G.
l.24 \tikz{\node[blue]{\show\current@color
\show\pgf@strokecolor@global This ...
?
> \pgf@strokecolor@global=macro:
->\xcolor@ {}{0 0 1 rg 0 0 1 RG}{rgb}{0,0,1}.
l.24 ...\current@color\show\pgf@strokecolor@global
This is in blue. \sbox{\m...
?
\color{blue}
が使用された場合は、\current@color
(pdf は) 青色であることを示しています。ただし、このnode[blue]
場合、テキストは青色ですが、\current@color
(pdf は) 黒色です。
\sbox
これは、PDFバックエンドまたはDVIドライバによって維持されるカラースタックの状態を「知らない」ため重要であり、保存されたテキストの色を設定するだけです。\current@color
この\resetcurrentcolor
コマンドは実際には色を設定しません ( または を発行しませ\special
ん) 。PGF によって最後に設定されたストロークの色を使用するように\pdfliteral
再定義するだけです。\current@color