콘텐츠에 \sbox{}\usebox{}가 포함된 경우 TikZ 노드의 콘텐츠에 색상 옵션을 적용하는 방법은 무엇입니까?

콘텐츠에 \sbox{}\usebox{}가 포함된 경우 TikZ 노드의 콘텐츠에 색상 옵션을 적용하는 방법은 무엇입니까?

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.};}

생산하다

파란색과 검정색의 저장 상자

이 질문, 저를 감독해 준 Sašo Živanović에게도 빚을 지고 있는 것 같습니다.

\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

이는 라텍스가 이해하는 대로 현재 색상을 설정하지 않는 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) 검정색임을 보여줍니다.

\sboxPDF 백엔드 또는 DVI 드라이버가 유지 관리하는 색상 스택의 상태를 "알지" 못하고 저장된 텍스트의 색상만 설정하므로 이는 중요합니다 .\current@color

이 명령은 실제로 색상을 설정하지 않고(no 또는 \resetcurrentcolor발행 ) 단지 PGF에서 마지막으로 설정한 획 색상을 사용하도록 재정의합니다.\special\pdfliteral\current@color

여기에 이미지 설명을 입력하세요

관련 정보