Tikz verschiebt den Ursprung beim Kompilieren in XeLaTeX im Vergleich zu PDFLaTeX

Tikz verschiebt den Ursprung beim Kompilieren in XeLaTeX im Vergleich zu PDFLaTeX

Wenn ich im unten angegebenen Code mit WinEdt und XeLaTeX kompiliere, sieht meine Gleichung folgendermaßen aus:

Bildbeschreibung hier eingeben

Wenn ich jedoch PFDLaTeX zum Kompilieren verwende, wird die Gleichung korrekt ausgegeben:

Bildbeschreibung hier eingeben

Wie kann ich die Gleichung mit XeLaTeX korrekt anzeigen?

Hier ist der Code:

\documentclass{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}
\usepackage{tikz}

\usetikzlibrary{tikzmark,calc,arrows,shapes,fit,decorations.pathreplacing,pgfplots.groupplots, matrix}
\tikzset{every picture/.style={remember picture}}

\begin{document}

\begin{equation}
\tikz{\node{\subnode{d4}{$\hat{{\theta}}_{BLU}(k+1)$} = \subnode{d5}{$\hat{{\theta}}_{BLU}(k)$} + \subnode{d6} {$\mathbf{K_{B}}(k+1)$}\subnode{d7}{$\big(\underbrace{z(k+1)-\mathbf{h}'(k+1)\hat{{\theta}}_{BLU}(k)}\big)$}};}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] + (245:2.2cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(255:1.1cm) node[anchor=north,text = black] {previous estimate};
\draw[blue,thick,->] (d6) to [in=90,out=265] +(279:2.0cm) node[anchor=north,text = black,text width=3cm,align=center]
 {(gain)\\ The weight\\ of the adjustment};
\draw[blue,thick,->] (d7) to [in=90,out=265] +(335:1.6cm) node[anchor=north,text = black,text width=4cm,align=center]
 {residual prediction\\ how far the previous\\ estimation from the \\ current measurement};
\end{tikzpicture}

\end{document}

Antwort1

Ich verstehe Ihren Ansatz nicht ganz, aber so würde ich es machen. Es funktioniert mit xelatex und pdflatex.

Der Hauptpunkt ist die Definition eines Makros

\tikznode[..options..]{..label..}{..contents..}

um den Inhalt zu markieren, aus dem die Pfeile stammen. Um Pfeile und Text hinzuzufügen, verwenden Sie

\begin{tikzpicture}[remember picture,overlay]
  ... tikz code using the labels defined by \tikznode ...
\end{tikzpicture}

Definieren Sie den Befehl \tikznodein der Präambel als

\usepackage{tikz}
\newcommand\tikznode[3][]%
   {\tikz[remember picture,baseline=(#2.base)]
      \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
   }

Bildbeschreibung hier eingeben

\documentclass{book}
\usepackage{tikz}
\newcommand\tikznode[3][]%
   {\tikz[remember picture,baseline=(#2.base)]
      \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
   }
\begin{document}

\begin{equation}
\tikznode{d4}{$\hat{{\theta}}_{BLU}(k+1)$} = \tikznode{d5}{$\hat{{\theta}}_{BLU}(k)$}
+ \tikznode{d6}{$\mathbf{K_{B}}(k+1)$}\tikznode{d7}{$\big(\underbrace{z(k+1)-\mathbf{h}'(k+1)\hat{{\theta}}_{BLU}(k)}\big)$}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] + (245:2.2cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(255:1.1cm) node[anchor=north,text = black] {previous estimate};
\draw[blue,thick,->] (d6) to [in=90,out=265] +(279:2.0cm) node[anchor=north,text = black,text width=3cm,align=center]
 {(gain)\\ The weight\\ of the adjustment};
\draw[blue,thick,->] (d7) to [in=90,out=265] +(335:1.6cm) node[anchor=north,text = black,text width=4cm,align=center]
 {residual prediction\\ how far the previous\\ estimation from the \\ current measurement};
\end{tikzpicture}

\end{document}

Antwort2

An @gernot: es ist das gleiche Problem, da die Lösung gilt

\documentclass{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}
\usepackage{tikz}

\usetikzlibrary{tikzmark,calc,arrows,shapes,fit,decorations.pathreplacing,pgfplots.groupplots, matrix}
\tikzset{every picture/.style={remember picture}}

\begin{document}

\makeatletter
\def\pgfsys@hboxsynced#1{%
  {%
    \pgfsys@beginscope%
    \setbox\pgf@hbox=\hbox{%
      \hskip\pgf@pt@x%
      \raise\pgf@pt@y\hbox{%
        \pgf@pt@x=0pt%
        \pgf@pt@y=0pt%
        \special{pdf: content q}%
        \pgflowlevelsynccm% 
        \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
        \special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
        \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
        \wd#1=0pt%
        \ht#1=0pt%
        \dp#1=0pt%
        \box#1%
        \pgfsys@invoke{n Q Q Q}%
      }%
      \hss%
    }%
    \wd\pgf@hbox=0pt%
    \ht\pgf@hbox=0pt%
    \dp\pgf@hbox=0pt%
    \pgfsys@hbox\pgf@hbox%
    \pgfsys@endscope%
  }%
}
\makeatother


\begin{equation}
\tikz{\node{\subnode{d4}{$\hat{{\theta}}_{BLU}(k+1)$} = \subnode{d5}{$\hat{{\theta}}_{BLU}(k)$} + \subnode{d6} {$\mathbf{K_{B}}(k+1)$}\subnode{d7}{$\big(\underbrace{z(k+1)-\mathbf{h}'(k+1)\hat{{\theta}}_{BLU}(k)}\big)$}};}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] + (245:2.2cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(255:1.1cm) node[anchor=north,text = black] {previous estimate};
\draw[blue,thick,->] (d6) to [in=90,out=265] +(279:2.0cm) node[anchor=north,text = black,text width=3cm,align=center]
 {(gain)\\ The weight\\ of the adjustment};
\draw[blue,thick,->] (d7) to [in=90,out=265] +(335:1.6cm) node[anchor=north,text = black,text width=4cm,align=center]
 {residual prediction\\ how far the previous\\ estimation from the \\ current measurement};
\end{tikzpicture}

\end{document}

Das Ergebnis ist das gleiche wie beim zweiten Snap des OP

verwandte Informationen