1

Why does text made by tikz node not align with other text on the same line? That is to say, they are not on the same baseline. And how to solve this?

Hereafter is the example code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
aa\tikz \node[inner sep=0pt,opacity=1]at (0,0){|by tikz|};aa
\end{document}

enter image description here

lyl
  • 2,727
  • There are many related questions, just google tikz baseline text or tikz inline baseline : https://tex.stackexchange.com/questions/416226. In addition the manual is full of baseline examples, e. g. $A \mathbin{\tikz[baseline] \draw[-»] (0pt,.5ex) -- (3ex,.5ex);} B$ – Dr. Manuel Kuehner May 19 '18 at 09:52

1 Answers1

5

There are many errors in your code. First, you need to load the tikz-package. Second, do not use the backslash for opening and closing the node-options. And, finally, you can use the baseline-key to achieve the desired effect.

Here is the code.

\documentclass{article}
\usepackage{tikz}

\begin{document}
aa\tikz[baseline=(A.base)]\node[inner sep=0pt] (A) at (0,0){|by tikz|};aa
\end{document}
Marian G.
  • 1,951
  • 1
  • 9
  • 14