TransWikia.com

Resize tikzpicture in input

TeX - LaTeX Asked by eric gabo ekeberg nilsen on April 27, 2021

I’m attempting to insert a tikspicture into my text. However, rather than having the code in actual document, I bring it in as an input, such as this:

begin{figure}[h]

input{Grafikk/ValuesToOpinion}

caption{Lorem Ipsum}
label{Dolor Sit Amet}
end{figure} 

Doing it in this was will make it considerably easier if I want to change something about the figure, and makes the document a lot cleaner. The picture becomes somewhat larger than I would like, and goes outside the page. I can’t seem to find a way to rescale it either. Using input{} within a includregraphics{} just returns an error, as it expects a regular picture format. I’ve also attempted to use tikzset{every picture/.style={line width=0.5pt}} in the preamble, but that gives no change at all. Anyone got any tips?

MWE:
Document:

 documentclass{report}
  usepackage{graphicx}
  usepackage{tikz}
   usepackage{kantlipsum}

begin{document}
 kant[5]

 begin{figure}[h]
 input{tixzfigure}   
  label{something}
  caption{something else}  
   end{figure}
   Dolor sit amet
  end{document}

tikz-figure:

 begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
 

    %Shape: Triangle [id:dp09448679081661204] 
    draw   (316.15,13) -- (635.3,161.2) -- (-3,161.2) -- cycle ;
    %Shape: Rectangle [id:dp80163133792419] 
     draw   (-7.7,25) -- (655.3,25) -- (655.3,65) -- (-7.7,65) -- cycle ;
    end{tikzpicture}

Also, all the tikz code is from this website https://www.mathcha.io/editor

One Answer

Having explored the topic of scaling, other -quite obvious- options to fit a figure larger than the text area are:

(1) Use the landscape mode, or

(2) use the margins.

For #2 I use the package xcoffins. The material (text, images, tikzfigures, tables, etc.) are place in special boxes that can be attached to other similar boxes in may ways, including the addition of X & Y offsets (applied as (X offset, Y offset) by the Join command).

This second facility allows for an easy placement of the material anywhere on the physical page.

The boxes behaves as a text object, so they are not a float, and are typeset at the current insertion point.

The same package allows for rotation of the boxes, as it is shown in the second page.

x1

x2

documentclass{report}
usepackage{graphicx}
usepackage{tikz}


usepackage{caption}
usepackage{xcoffins}

NewCoffinFramex
NewCoffintikzFig

usepackage{showframe}
renewcommand*ShowFrameColor{color{red}}

begin{document}
        
As any dedicated reader can clearly see, the Ideal of
practical reason is a representation of, as far as I know, the things
in themselves; as I have shown elsewhere, the phenomena should only be
used as a canon for our understanding.


begin{figure}[h]
    centering
    input{qtikzfigure2}   
    label{something}
    caption{something else out of page}  
end{figure}

Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.
Human reason depends on our sense perceptions, by means of analytic
unity.

bigskip

SetHorizontalCoffintikzFig{%
input{qtikzfigure2}    
}   
        
JoinCoffins*Framex[l,t]tikzFig[l,t](-60pt,0pt) % shift towards left margin
noindentTypesetCoffinFramex
vspace*{CoffinTotalHeighttikzFig}    
captionof{figure}{Input from file and X offset added to center}

bigskip
    
As is shown in the writings of Aristotle, the things
in themselves (and it remains a mystery why this is the case) are a
representation of time. Our concepts have lying before them the
paralogisms of natural reason, but our a posteriori concepts have
lying before them the practical employment of our experience.

newpage

SetHorizontalCoffinFramex{}

RotateCoffintikzFig{90}
JoinCoffins*Framex[l,b]tikzFig[r,vc](textwidth/2,0pt) % centering 
noindentTypesetCoffinFramex
vspace*{CoffinTotalHeighttikzFig}    
captionof{figure}{Input from file and X offset added to center plus rotated}


end{document}

The file qtikzfigure2.tex used contains the tikzfigure provided by the OP with a rectangle and a triangle overflowing the text area when inserted at the left margin (Fig. 1).

Correct answer by Simon Dispa on April 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP