文本内嵌于 tikz 图片

文本内嵌于 tikz 图片
    \documentclass[12pt]{article}
    \usepackage{fixltx2e,graphicx,amsmath,mathptmx,tikz,tkz-euclide,pgfplots} %for math
    \usetkzobj{all}
    \usetikzlibrary{calc}
    \begin{document}
    This is a square
    \begin{tikzpicture}[thick]
    \coordinate (L) at (0,0);
    \coordinate (M) at (2,0);
    \coordinate (N) at (2,2);
    \coordinate (P) at (0,2);
    \draw 
    (L) node[below left] {\footnotesize{$L$}} --
    (M) node[below right] {\footnotesize{$M$}} --
    (N) node[above right] {\footnotesize{$N$}} --
    (P) node[above left] {\footnotesize{$P$}} -- 
    cycle;
    \tkzLabelSegment[below=2pt](L,M){\footnotesize{$4$cm}}
    \end{tikzpicture}
    Find its area.
    \end{document}

有什么方法可以让文本与方块对齐吗?

答案1

您可以使用基线选项。

\documentclass[12pt]{article}
\usepackage{fixltx2e,graphicx,amsmath,mathptmx,tikz,tkz-euclide,pgfplots} %for math
\usetkzobj{all}
\usetikzlibrary{calc}
\begin{document}
This is a square
\begin{tikzpicture}[baseline,thick]
\coordinate (L) at (0,0);
\coordinate (M) at (2,0);
\coordinate (N) at (2,2);
\coordinate (P) at (0,2);
\draw
(L) node[below left] {\footnotesize{$L$}} --
(M) node[below right] {\footnotesize{$M$}} --
(N) node[above right] {\footnotesize{$N$}} --
(P) node[above left] {\footnotesize{$P$}} --
cycle;
\tkzLabelSegment[below=2pt](L,M){\footnotesize{$4$cm}}
\end{tikzpicture}
Find its area.
\end{document}

在此处输入图片描述

有了\begin{tikzpicture}[baseline={(current bounding box.center)},thick],我们得到

在此处输入图片描述

相关内容