
나는 내 메모에 대한 멋진 "설명선"을 갖기 위해 몇 가지 작은 명령을 고안했습니다. 다음 MWE를 고려하십시오(문제는 거기에도 설명되어 있습니다).
\documentclass{book}
\usepackage{tikz}
\tikzset{remember picture,
round mark/.style={
circle, draw=yellow, minimum size=5mm, fill opacity=0.5, fill=yellow,
},
}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage{siunitx}
\DeclareSIUnit{\krypt}{\ensuremath{\mathcal{K}r}}
\usepackage{xparse}
\newcommand{\roundmark}[1]{\tikz[overlay, remember picture, baseline=-0.5ex]
\node [round mark, anchor=west] (#1) {};}
\NewDocumentCommand \addline {O{} m m }{%
\begin{tikzpicture}[overlay,remember picture]
\draw[ultra thick, yellow, ->, #1 ] (expl@#2) -- (#3);
\end{tikzpicture}%
}
\NewDocumentCommand \margincallout {O{} m +m }{%
\marginpar{
\begin{tikzpicture}[overlay,remember picture]
\node [ anchor=west, draw=orange, fill=yellow!20,
text width=\marginparwidth, align=left, font=\small,
#1 ] (expl@#2)
at (0,0) {
#3
};
\draw[ultra thick, yellow,->] (expl@#2) -- (#2);
\end{tikzpicture}}%
}
\begin{document}
I can mark thing in \roundmark{a}the main text and then have nice callouts from the marginpar to this point.
\margincallout{a}{This is a callout, a nice one and it's ok.}
% thanks @bloodworks http://tex.stackexchange.com/a/62285/38080
% require package capt-of
\begin{figure}[htb]
\begin{center}
\begin{tikzpicture}[remember picture,
]
\begin{axis}[
width=7cm,
xmin=0, xmax=10, domain=0:10,
enlarge y limits = 0.2,
ylabel = {Sensor R (\si{k\ohm})},
xlabel = {Kryporad (\si{\krypt})},
legend pos = north west,
legend style={nodes=right},
]
\addplot[red] {134 + 18.5*x + 15.0*sin(deg(0.664*x))};
\addplot[blue, dashed] {143 + 16.8*x};
\legend{non-linear fit, linear fit}
\end{axis}
\node [round mark] (hor-axis) at (4,-0.5) {};
\node [round mark] (ver-axis) at (-0.5,4) {};
%\draw (0,0) grid (5,5);
\end{tikzpicture}
\end{center}
\caption{With a bit of guesswork I can mark things in the graphics, too}
\label{fig:calibR}
\end{figure}
\margincallout[yshift=3cm]{hor-axis}{\textbf{Always} name the axis and columns, and use units when needed}
\addline{hor-axis}{ver-axis}
Uncomment the following to see the error:
%But if I want to put the callout \textbf{before} the mark,
%as in \margincallout{future}{A forward callout} it will not work, and give me an error.
%The mark will be \roundmark{future}here, for example.
\end{document}
좋은 (IMHO) 결과를 출력합니다.
문제는 때때로 \margincallout
명령 을 갖는 것이 유용하다는 것입니다.~ 전에노드 \roundmark
이름을 정의하는 입니다.
어쨌든 문서에는 두 번의 패스가 필요합니다. 레이블에 대한 전방 참조와 같은 것을 작성하는 것이 가능할 것이라고 생각했지만... 해결책을 찾을 수 없습니다.
다음 패스에서 해결될 노드를 참조하는 것이 가능합니까?
업데이트:
그래서 으로 시도해 보았지만 tikzmark
여기서 뭔가 이상해지는 것 같습니다. 바라보다:
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{remember picture,
round mark/.style={
circle, draw=yellow, minimum size=5mm, fill opacity=0.5, fill=yellow,
},
}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage{siunitx}
\DeclareSIUnit{\krypt}{\ensuremath{\mathcal{K}r}}
\usepackage{xparse}
\newcommand{\rtikzmark}[1]{\tikzmark[{
\node [baseline=-0.5ex, round mark, anchor=west]{}}]{#1}}
\NewDocumentCommand \addline {O{} m m }{%
\begin{tikzpicture}[overlay,remember picture]
\draw[ultra thick, yellow, ->, #1 ] (expl@#2) -- (pic cs:#3);
\end{tikzpicture}%
}
\NewDocumentCommand \margincallout {O{} m +m }{%
\marginpar{
\begin{tikzpicture}[overlay,remember picture]
\node [ anchor=west, draw=orange, fill=yellow!20,
text width=\marginparwidth, align=left, font=\small,
#1 ] (expl@#2)
at (0,0) {
#3
};
\draw[ultra thick, yellow,->] (expl@#2) -- (pic cs: #2);
\end{tikzpicture}}%
}
\begin{document}
I can mark thing in \rtikzmark{a}the main text and then have nice callouts from the marginpar to this point.
\margincallout{a}{This is a callout, a nice one and it's ok.}
% thanks @bloodworks http://tex.stackexchange.com/a/62285/38080
% require package capt-of
\begin{figure}[htb]
\begin{center}
\begin{tikzpicture}[remember picture,
]
\begin{axis}[
width=7cm,
xmin=0, xmax=10, domain=0:10,
enlarge y limits = 0.2,
ylabel = {Sensor R (\si{k\ohm})},
xlabel = {Kryporad (\si{\krypt})},
legend pos = north west,
legend style={nodes=right},
]
\addplot[red] {134 + 18.5*x + 15.0*sin(deg(0.664*x))};
\addplot[blue, dashed] {143 + 16.8*x};
\legend{non-linear fit, linear fit}
\end{axis}
\node [round mark] at (4,-0.5) {}; \tikzmark{hor-axis};
\node [round mark] at (-0.5,4) {}; \tikzmark{ver-axis};
%\draw (0,0) grid (5,5);
\end{tikzpicture}
\end{center}
\caption{With a bit of guesswork I can mark things in the graphics, too}
\label{fig:calibR}
\end{figure}
\margincallout[yshift=3cm]{hor-axis}{\textbf{Always} name the axis and columns, and use units when needed}
\addline{hor-axis}{ver-axis}
Uncomment the following to see the error:
But if I want to put the callout \textbf{before} the mark,
as in \margincallout{future}{A forward callout} it will not work, and give me an error.
The mark will be \rtikzmark{future}here, for example.
\end{document}
첫 번째 호출(텍스트 내)은 일종의 작업이지만 그 다음에는 선이 그려지지 않습니다. 그리고 두 번째와 세 번째 호출(하나의 표시 지점~ 안으로그래프) 전체 그림을 오버레이로 변환합니다...
좋은 점은 전방 콜아웃이 작동하지만 선이 그려지지 않는다는 것입니다. 어찌할 바를 모르는.
답변1
(이것을 추가하고 있습니다.~ 위에왜냐하면 그것이 원래의 답변을 대체하고 그래서 누군가가 단지무엇그리고 그것에 대해 신경 쓰지 않았다어떻게,언제, 그리고 확실히 그렇지 않습니다왜원래 답변을 읽지 않아도됩니다.)
Stop Press : tikzmark
다시 진화
tikzmark
은(는) 처음 창설된 이후 주로 이 사이트의 질문에 따라 상당한 발전을 겪었습니다. 그 과정에서 얻은 주요 기능 중 하나는 저장한 좌표를 사용하는 기능이었습니다.이전의문서에서 해당 항목이 발생합니다.
처음부터 가지고 있던 속성 중 하나는 사용하도록 의도되었다는 것입니다.밖의명령 \tikz
이나 tikzpicture
환경. 내부적으로는 TikZ의 일반 좌표 기억 서비스에 대한 전체 액세스 권한을 가지므로 \tikzmark
.
하지만 앞서 언급한 핵심 기능은~ 아니다TikZ가 제공하는 것. tikzpicture
선언하기 전에 내부에서 좌표를 참조할 수 있는 방법이 없습니다 . 그래서 그렇게 하고 싶다면 새로운 것이 필요합니다.
이 질문의 주요 특징은 의뢰인이 외부 좌표와 내부 좌표를 참조하기 위해 동일한 메커니즘을 사용하기를 원한다는 것입니다 tikzpicture
. 따라서 tikzpictures 내에서 투시 좌표 기능을 제공하는 올바른 방법은 tikzmark를 확장하는 것입니다.
이것은 매우 쉬운 것으로 판명되었습니다. 간단히 말해서, tikzmark가 하는 일은 레이블을 tikzpicture의 원점과 연결하는 것이며 모든 무거운 작업은 좌표계에서 수행됩니다. 확장은 잠재적인 오프셋을 추가하여 tikz가 페이지에서 해당 tikzpicture의 원본 위치를 파악한 후 오프셋을 적용하는 것입니다. 이를 테스트와 결합하여 우리가 tikzpicture 안에 있는지 확인하면 모든 것이 완료됩니다.
(이 새 버전으로 전환하는 경우 다시 컴파일하기 전에 aux 파일을 삭제해야 합니다. 그렇지 않으면 처음 다시 컴파일할 때 많은 오류가 발생하게 됩니다.)
구문내부에tikzpicture는 \tikzmark{label}{coordinate}
예를 들어 입니다 \tikmark{a}{(3,4)}
. 이는 좌표가 현재 그림의 (pic cs:a)
한 지점을 가리킨다는 의미입니다.(3,4)
다음에서 tikzmark의 새 버전을 다운로드할 수 있습니다.깃허브: 다운로드 tikzmark.dtx
하고 실행하여 tex tikzmark.dtx
파일을 생성합니다.
그래서새로운, 개선된 \tikzmark
, 코드는 이제 다시 한 번 합리적인 상태로 돌아갑니다.
\documentclass{book}
%\url{http://tex.stackexchange.com/q/295903/86}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{remember picture,
round mark/.style={
circle, draw=yellow, minimum size=5mm, fill opacity=0.5, fill=yellow,
},
}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage{siunitx}
\DeclareSIUnit{\krypt}{\ensuremath{\mathcal{K}r}}
\usepackage{xparse}
\newcommand{\rtikzmark}[1]{\tikzmark[{
\node [baseline=-0.5ex, round mark, anchor=west]{}}]{#1}}
\NewDocumentCommand \addline {O{} m m }{%
\begin{tikzpicture}[overlay,remember picture]
\draw[ultra thick, yellow, ->, #1 ] (expl@#2) -- (pic cs:#3);
\end{tikzpicture}%
}
\NewDocumentCommand \margincallout {O{} m +m }{%
\marginpar{
\begin{tikzpicture}[overlay,remember picture]
\node [ anchor=west, draw=orange, fill=yellow!20,
text width=\marginparwidth, align=left, font=\small,
#1 ] (expl@#2)
at (0,0) {
#3
};
\draw[ultra thick, yellow,->] (expl@#2) -- (pic cs:#2);
\end{tikzpicture}}%
}
\begin{document}
I can mark thing in \rtikzmark{a}the main text and then have nice callouts from the marginpar to this point.
\margincallout{a}{This is a callout, a nice one and it's ok.}
% thanks @bloodworks http://tex.stackexchange.com/a/62285/38080
% require package capt-of
\begin{figure}[htb]
\begin{center}
\begin{tikzpicture}[remember picture,
]
\begin{axis}[
width=7cm,
xmin=0, xmax=10, domain=0:10,
enlarge y limits = 0.2,
ylabel = {Sensor R (\si{k\ohm})},
xlabel = {Kryporad (\si{\krypt})},
legend pos = north west,
legend style={nodes=right},
]
\addplot[red] {134 + 18.5*x + 15.0*sin(deg(0.664*x))};
\addplot[blue, dashed] {143 + 16.8*x};
\legend{non-linear fit, linear fit}
\end{axis}
\node [round mark] at (4,-0.5) (hor-axis) {};
\node [round mark] at (-0.5,4) (ver-axis) {};
\node [round mark] at (0,0) (origin) {};
\tikzmark{hor-axis}{(hor-axis)}
\tikzmark{ver-axis}{(ver-axis)}
\tikzmark{origin}{(origin)}
%\draw (0,0) grid (5,5);
\end{tikzpicture}
\end{center}
\caption{With a bit of guesswork I can mark things in the graphics, too}
\label{fig:calibR}
\end{figure}
\margincallout[yshift=4cm]{hor-axis}{\textbf{Always} name the axis and columns, and use units when needed}
\addline{hor-axis}{ver-axis}
\addline{hor-axis}{origin}
Uncomment the following to see the error:
But if I want to put the callout \textbf{before} the mark,
as in \margincallout{future}{A forward callout} it will not work, and give me an error.
The mark will be \rtikzmark{future}here, for example.
\end{document}
(아래 이미지와 동일)
원래 답변은 다음과 같습니다.
여기에 몇 가지가 있습니다 ...
tikzmark
(첫째, 와의 상호작용에서 버그를 발견했습니다 marginpar
. 버그가 있는 버전이 CTAN의 버전보다 최신 버전이라는 의심이 들었습니다.아무것두 번째 예에서는 버그 버전을 사용하는 경우입니다. 아무튼 업데이트 버전은github에서 사용 가능.)
둘째, 더 중요한 것은 \tikzmark
사용하도록 설계되지 않았다는 것입니다.내부에환경 tikzpicture
. 그렇게 하면 상황이 잘못됩니다. 정규식을 사용하여 HTML을 구문 분석하는 것보다 훨씬 더 심각합니다. 요점은 tikzpicture
환경 내부에 있는 경우 tikz의 모든 노드 및 좌표 위치 지정 항목에 액세스할 수 있으며 tikzmark가 필요하지 않다는 것입니다.
(내가 "tikzpicture 내에서 tikzmark를 사용하지 마십시오"라고 몇 번이나 말하는지는 중요하지 않은 것 같습니다. 사람들은 그것을 사용하고 싶어하는 것 같습니다. 아마도 총알을 깨물고 작동하게 만드는 방법을 알아내야 할 것입니다. )
물론 이는 두 가지 버전의 콜아웃 코드가 필요하다는 것을 의미합니다. 하나는 마크가 tikz사진에 있을 때를 위한 것이고 다른 하나는 그렇지 않을 때를 위한 것입니다. 그것을 피하기 위해 이것을 코딩하는 멋진 방법이 있을 수도 있지만, 나는 작은 두뇌를 가진 곰이고 지금 이 시간에는 그것을 광범위하게 생각할 수 없습니다.
따라서 이것이 스타일 콘테스트에서 결코 승리할 수는 없지만 여기에 올바른 결과가 있어야 한다고 생각하는 작업 버전의 코드가 있습니다.
\documentclass{book}
%\url{http://tex.stackexchange.com/q/295903/86}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{remember picture,
round mark/.style={
circle, draw=yellow, minimum size=5mm, fill opacity=0.5, fill=yellow,
},
}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage{siunitx}
\DeclareSIUnit{\krypt}{\ensuremath{\mathcal{K}r}}
\usepackage{xparse}
\newcommand{\rtikzmark}[1]{\tikzmark[{
\node [baseline=-0.5ex, round mark, anchor=west]{}}]{#1}}
\NewDocumentCommand \addline {O{} m m }{%
\begin{tikzpicture}[overlay,remember picture]
\draw[ultra thick, yellow, ->, #1 ] (expl@#2) -- (pic cs:#3);
\end{tikzpicture}%
}
\NewDocumentCommand \addlineb {O{} m m }{%
\begin{tikzpicture}[overlay,remember picture]
\draw[ultra thick, yellow, ->, #1 ] (expl@#2) -- (#3);
\end{tikzpicture}%
}
\NewDocumentCommand \margincallout {O{} m +m }{%
\marginpar{
\begin{tikzpicture}[overlay,remember picture]
\node [ anchor=west, draw=orange, fill=yellow!20,
text width=\marginparwidth, align=left, font=\small,
#1 ] (expl@#2)
at (0,0) {
#3
};
\draw[ultra thick, yellow,->] (expl@#2) -- (pic cs:#2);
\end{tikzpicture}}%
}
\NewDocumentCommand \margincalloutb {O{} m +m }{%
\marginpar{
\begin{tikzpicture}[overlay,remember picture]
\node [ anchor=west, draw=orange, fill=yellow!20,
text width=\marginparwidth, align=left, font=\small,
#1 ] (expl@#2)
at (0,0) {
#3
};
\draw[ultra thick, yellow,->] (expl@#2) -- (#2);
\end{tikzpicture}}%
}
\begin{document}
I can mark thing in \rtikzmark{a}the main text and then have nice callouts from the marginpar to this point.
\margincallout{a}{This is a callout, a nice one and it's ok.}
% thanks @bloodworks http://tex.stackexchange.com/a/62285/38080
% require package capt-of
\begin{figure}[htb]
\begin{center}
\begin{tikzpicture}[remember picture,
]
\begin{axis}[
width=7cm,
xmin=0, xmax=10, domain=0:10,
enlarge y limits = 0.2,
ylabel = {Sensor R (\si{k\ohm})},
xlabel = {Kryporad (\si{\krypt})},
legend pos = north west,
legend style={nodes=right},
]
\addplot[red] {134 + 18.5*x + 15.0*sin(deg(0.664*x))};
\addplot[blue, dashed] {143 + 16.8*x};
\legend{non-linear fit, linear fit}
\end{axis}
\node [round mark] at (4,-0.5) (hor-axis) {};
\node [round mark] at (-0.5,4) (ver-axis) {};
\node [round mark] at (0,0) (origin) {};
%\draw (0,0) grid (5,5);
\end{tikzpicture}
\end{center}
\caption{With a bit of guesswork I can mark things in the graphics, too}
\label{fig:calibR}
\end{figure}
\margincalloutb[yshift=4cm]{hor-axis}{\textbf{Always} name the axis and columns, and use units when needed}
\addlineb{hor-axis}{ver-axis}
\addlineb{hor-axis}{origin}
Uncomment the following to see the error:
But if I want to put the callout \textbf{before} the mark,
as in \margincallout{future}{A forward callout} it will not work, and give me an error.
The mark will be \rtikzmark{future}here, for example.
\end{document}