4

I am beginning with TikZ. How to do the simplest square of defined position, width&height, eventually color with text inside please ?

I used before the command framebox, but I don't have the same result with TikZ.

Thanks a lot,

Thomas

  • Welcome to TeX.SE. It is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it.While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Nov 4 '14 at 20:34
5

Does this help:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}

\newcommand*{\MyNode}[3][]{%
\begin{tikzpicture}
    \node[#1] (A) at #2 {#3};
    \node [anchor=west, align=left, text width=8cm] at (A.east) {\tiny#1};
\end{tikzpicture}%
}

\begin{document}
\MyNode{(0,0)}{x}

\MyNode[draw=red]{(0,0)}{1}

\MyNode[draw=red, inner sep=0, outer sep=0]{(0,0)}{2}

\MyNode[draw=red, inner sep=0, outer sep=0, minimum width=1cm]{(0,0)}{3}

\MyNode[draw=red, inner sep=0, outer sep=0, minimum height=1cm]{(0,0)}{4}

\MyNode[draw=red, inner sep=0, outer sep=0, minimum width=1cm, minimum height=1cm, fill=yellow]{(0,0)}{5}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.