2

I want to draw a rectangle which starts in these coordinates: from northwest(3,0) to southeast(4,-2). Here is the code:

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{caption}
\usetikzlibrary{arrows}
\usepackage{color}
\usepackage[colorlinks]{hyperref}
\usepackage{pgfplots}

\begin{document}

\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\

\noindent
\begin{tikzpicture}
\draw[pattern=north east lines, pattern color=black] (3,0) rectangle ++(1,2);
\end{tikzpicture}

\end{document}

But it doesn't work. So I tried adding [shift={(3,0)},...] and [xshift={3},...]. They also didn't work. I can't move a simple rectangle. Here is the picture that I want to draw: I just want to draw pattern filled rectangle first

closed as off-topic by Bobyandbob, Stefan Pinnow, TeXnician, Troy, Phelype Oleinik Jun 2 '18 at 13:34

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    Since there is no other content in the drawing it doesn't surprise me that \draw[pattern=north east lines, pattern color=black] (0,0) rectangle ++(1,2); and \draw[pattern=north east lines, pattern color=black] (3,0) rectangle ++(1,2); give the same output. What do you want to achieve? Why do you need to start at (3,0) rather than (0,0). What is the expected output (can you add a picture that shows the difference between the current and desired state)? – moewe May 31 '18 at 13:15
  • 3
    TikZ shrinks down its final box to the smallest rectangle upon exit no matter what the coordinates are. They are internal coordinates not page coordinates. – percusse May 31 '18 at 13:16
  • 3
    For me it would be illogical if the coordinates were relative to the page. The diagram is a separate environment. If you want to tell TeX to move the box that is the tikzpicture 3cm right you could add \hspace*{3cm} just before it. @moewe's suggestion would almost work, but because of the default inner sep of a node, the left edge of the diagram would actually be at -0.333em of the coordinate system of the tikzpicture. On the other hand, something like \path (0,0) -- (3,0); would work I think, or add inner sep=0 to the node options. – Torbjørn T. May 31 '18 at 13:40
  • 3
    @Rageful I think you have a different idea of how TikZ works. TeX doesn't understand anything about graphics. It just stacks boxes. TikZ tells to TeX that I'm a box of <x, y> size and place me on the page when it is my turn. If you want page coordinates TikZ also has some capabilities but not via shifting coordinates. Can you reword your question about what to draw and where to draw it? – percusse May 31 '18 at 13:45
  • 4
    I'm voting to close this question as solved in the comments. – Bobyandbob Jun 2 '18 at 10:17