![文本内嵌于 tikz 图片](https://linux22.com/image/306034/%E6%96%87%E6%9C%AC%E5%86%85%E5%B5%8C%E4%BA%8E%20tikz%20%E5%9B%BE%E7%89%87.png)
\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]
,我们得到