Till now I just create a desired picture for example with QTikz or Tikz-EDT and pass the code afterwards to my document. To fit the picture to the width of the paper I use \resizebox.

However, if the original picture is much to big the font will be downscaled. If the picture is some points less the width the font is getting bigger. Not much, but it seems not to be beautiful, if the font-size is slightly different in each picture. Of course I could just scale everything beside the font but then the picture gets messy as I originally create distances and witdhs of the node in relation to the font-size inside the editor.

As far as I know it is possible to define a specific boundingbox as the "frame" of a picture.

My question is, if it is possible to define/draw a rectangle with the concrete width of my paper inside a tikz-envorinment so when I create the picture I always "see" how wide the picture should be not to be scaled much at the end.

Something like this:

\defineasboundingbox{\draw start_x, start_y) rectangle (PAPERWIDTH, end_y);}  % <-- See remark below

Remark: this rectangle should be used as a reference point for my drawing showing me the witdh of my paper where the picture will be placed later inside a \resizebox

I can now draw my picture using the rectangle as a reference.

Or is there somy easier solution just to make sure the font-size is the same in every picture?

Many thanks in advance.

  • 2
    If you know the \textwidth of the document that has to contain your graphics, you can do \path[use as bounding box] (0,0) rectangle ++(<text width>,<your height>); or \useasboundingbox (0,0) rectangle ++(<text width>,<your height>);. – Max Aug 20 '18 at 16:43

Based on Max's very nice answer to one of my previous questions, such a frame could be defined using

    use bounding box relative coordinates/.style={
        shift={(current bounding box.south west)},
        x={(current bounding box.south east)},
        y={(current bounding box.north west)}

    \draw[black,dashed,use as bounding box] (0,0) rectangle (\textwidth,5cm);
    \begin{scope}[use bounding box relative coordinates]
    % Some tikz code in relative coordinates inside the rectangle

All contents in the scope environment have to be positionned in relative coordinates but at least, you can see when you are overfilling the box.

| improve this answer | |
  • @SRel, is the solution helpful ? – BambOo Aug 20 '18 at 19:48
  • Hey BambOo, I started implementing it however I did not get it to work. TikzEDT shows me the bounding box correctly but I have some issues placing something inside. This must be due to the relative positioning you mentioned. However many thanks for your effot. I just ended drawin a rectangle and use this as bounding box just to see the width of my current drawing. EDIT: I am using a matrix for node arrangement, what i have to say when inserting it? : \matrix [column sep=1.3cm,row sep=1cm, ampersand replacement=\&, nodes in empty cells, anchor=west] (table) at (current bounding box.west) ? – SRel Aug 21 '18 at 13:04
  • @SRel Sorry that did not work out for you. Could you edit your question or ask another one so we have a complete view of what you want to achieve with you matrix ? – BambOo Aug 21 '18 at 13:09
  • 1
    @SRel You don't have to do the drawing inside the use bounding box relative coordinates-scope. What I understood from your question is that you wanted to see a rectangle that would give you an indication of what width your complete drawing should have. @BambOo's answer does so, and conveniently also provides a way to draw relative to this bounding box, but it doesn't force it. Could you try with your \matrix outside the scope? – Max Aug 21 '18 at 14:30

Your Answer

