如何将 tiKZ、PGF 和 circuiTiKz 包中的图形与文档中的常规文本结合起来?

如何将 tiKZ、PGF 和 circuiTiKz 包中的图形与文档中的常规文本结合起来?

手册中给出的大多数示例仅显示来自 TiKZ、PGF 和 circuiTiKZ 包的图形。没有单个示例将这些图形嵌入到常规文档中。

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{circuitikz}% loads tikz automatically
\usepackage{wrapfig}
\newcommand\atikzpicture{%
    \begin{tikzpicture}[baseline=(Q.B)]%baseline is the base of Q
        \draw (0,0) to[short, o-] ++(0.5,0)
        node[npn, anchor=base](Q){};
    \end{tikzpicture}
    }
\begin{document}

Basically a Ti\emph{k}Z picture is a box, and you can put it where you like, even in the \atikzpicture\ flow of text; normally you'll have it between paragraph:

\atikzpicture

In the case above, the picture is basically a paragraph by itself, but you can put it even in a formula:
\begin{equation}
    \atikzpicture
\end{equation}

\begin{wrapfigure}{r}{0.5\linewidth}
    \centering
    \atikzpicture
    \caption{Look, mum, a transistor!}
    \label{fig:one}
\end{wrapfigure}
You can clearly put it in a wrap-figure like in this case where I need to add a bit of text to fill the spaces\dots 

Clearly you can use it in a floating figure, so that it can move around in the ``best place'' according to \LaTeX{} point of view\dots

\begin{figure}[htpb!]
    \centering
    \atikzpicture
    \caption{Look, dad, another one!}
    \label{fig:two}
\end{figure}

\end{document}

基本上,你不能放一个 TiZ 图片可能位于另一个图片中(例如,作为节点的内容),因此在将其放入移动参数中时需要非常小心。但基本上 --- 它会像您将要处理的那样,比如说,\includegraphics您应该是安全的。

答案2

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}
    
\lipsum[1]
\begin{center}
\begin{tikzpicture}
    \draw[draw=black,fill=cyan] (0,0) rectangle ++(5,2);
    \node at (2.5,1) {hello there};
\end{tikzpicture}
\end{center}
\lipsum[1]  
    
\end{document}

在此处输入图片描述

相关内容