TransWikia.com

Tikz picture position

TeX - LaTeX Asked by mathali on August 13, 2020

I want to take this figure opposite to 1 , how can I do? Actually how can I change picture’s position as I want?

 documentclass[twocolumn,10pt]{article}
    usepackage{pgf,tikz,pgfplots}
    pgfplotsset{compat=1.15}
    usepackage{mathrsfs}
    usetikzlibrary{arrows}
    pagestyle{empty}
    
    
    
    
    begin{document}
    definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451}
    definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
    textbf{1)}newline
    begin{tikzpicture}[scale=0.8, line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
    clip(-5.003269918455611,-3.3529348860915125) rectangle (10.415703512539228,5.13457342454785);
    fill[line width=2.pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] (-1.16,2.85) -- (-3.82,-1.57) -- (3.56,-1.55) -- cycle;
    draw [line width=2.pt,color=rvwvcq] (-1.16,2.85)-- (-3.82,-1.57);
    draw [line width=2.pt,color=rvwvcq] (-3.82,-1.57)-- (3.56,-1.55);
    draw [line width=2.pt,color=rvwvcq] (3.56,-1.55)-- (-1.16,2.85);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-2.7200080786122416,-1.56701899208296);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-0.9600210043918271,-1.562249379415696);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (1.1000722668585952,-1.5566664708215214);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (2.4001169195517105,-1.5531433145811606);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (0.2994927758991701,1.4894558868736556);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (1.60355056870581,0.27380879188441476);
    begin{scriptsize}
    draw [fill=rvwvcq] (-1.16,2.85) circle (2.5pt);
    draw [fill=rvwvcq] (-3.82,-1.57) circle (2.5pt);
    draw [fill=rvwvcq] (3.56,-1.55) circle (2.5pt);
    draw [fill=rvwvcq] (-2.7200080786122416,-1.56701899208296) circle (2.5pt);
    draw [fill=rvwvcq] (-0.9600210043918271,-1.562249379415696) circle (2.5pt);
    draw [fill=rvwvcq] (1.1000722668585952,-1.5566664708215214) circle (2.5pt);
    draw [fill=rvwvcq] (2.4001169195517105,-1.5531433145811606) circle (2.5pt);
    draw [fill=rvwvcq] (0.2994927758991701,1.4894558868736556) circle (2.5pt);
    draw [fill=rvwvcq] (1.60355056870581,0.27380879188441476) circle (2.5pt);
    end{scriptsize}
    end{tikzpicture}
    end{document}

enter image description here

I want to like that

enter image description here
I want like that

3 Answers

Add the following line in the code

tikz[baseline={([yshift=-1.2cm]current bounding box.west)}]{}

enter image description here

documentclass[twocolumn,10pt]{article}
    usepackage{pgf,tikz,pgfplots}
    pgfplotsset{compat=1.15}
    usepackage{mathrsfs}
    usetikzlibrary{arrows}
    pagestyle{empty}
    
    begin{document}
    definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451}
    definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
    textbf{1)}tikz[baseline={([yshift=-1.2cm]current bounding box.west)}]{
    begin{tikzpicture}[scale=0.8, line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
    clip(-5.003269918455611,-3.3529348860915125) rectangle (10.415703512539228,5.13457342454785);
    fill[line width=2.pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] (-1.16,2.85) -- (-3.82,-1.57) -- (3.56,-1.55) -- cycle;
    draw [line width=2.pt,color=rvwvcq] (-1.16,2.85)-- (-3.82,-1.57);
    draw [line width=2.pt,color=rvwvcq] (-3.82,-1.57)-- (3.56,-1.55);
    draw [line width=2.pt,color=rvwvcq] (3.56,-1.55)-- (-1.16,2.85);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-2.7200080786122416,-1.56701899208296);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-0.9600210043918271,-1.562249379415696);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (1.1000722668585952,-1.5566664708215214);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (2.4001169195517105,-1.5531433145811606);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (0.2994927758991701,1.4894558868736556);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (1.60355056870581,0.27380879188441476);
    end{tikzpicture}}
    end{document}

EDIT - To cater for the change in handrawn sketch and comments of OP

To use xshift you need to use the overlay option -- add the following line in your code just after begin{tikzpicture} options

remember picture, 
overlay, 
baseline={(current bounding box.base)}, 
yshift=-2cm, 
xshift=4cm,

The output--

enter image description here

MWE

documentclass[twocolumn,10pt]{article}
    usepackage{pgf,tikz,pgfplots}
    pgfplotsset{compat=1.15}
    usepackage{mathrsfs}
    usetikzlibrary{arrows, positioning, calc}
    pagestyle{empty}
    
    
    
    
    begin{document}
    definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451}
    definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
    textbf{1)}{
    begin{tikzpicture}[remember picture, 
                        overlay, 
                        baseline={(current bounding box.base)}, 
                        yshift=-2cm, 
                        xshift=4cm, 
                        scale=0.8, 
                        line cap=round,
                        line join=round,
                        >=triangle 45,
                        x=1.0cm,
                        y=1.0cm,]
    clip(-5.003269918455611,-3.3529348860915125) rectangle (10.415703512539228,5.13457342454785);
    fill[line width=2.pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] (-1.16,2.85) -- (-3.82,-1.57) -- (3.56,-1.55) -- cycle;
    draw [line width=2.pt,color=rvwvcq] (-1.16,2.85)-- (-3.82,-1.57);
    draw [line width=2.pt,color=rvwvcq] (-3.82,-1.57)-- (3.56,-1.55);
    draw [line width=2.pt,color=rvwvcq] (3.56,-1.55)-- (-1.16,2.85);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-2.7200080786122416,-1.56701899208296);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-0.9600210043918271,-1.562249379415696);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (1.1000722668585952,-1.5566664708215214);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (2.4001169195517105,-1.5531433145811606);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (0.2994927758991701,1.4894558868736556);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (1.60355056870581,0.27380879188441476);
    begin{scriptsize}
    draw [fill=rvwvcq] (-1.16,2.85) circle (2.5pt);
    draw [fill=rvwvcq] (-3.82,-1.57) circle (2.5pt);
    draw [fill=rvwvcq] (3.56,-1.55) circle (2.5pt);
    draw [fill=rvwvcq] (-2.7200080786122416,-1.56701899208296) circle (2.5pt);
    draw [fill=rvwvcq] (-0.9600210043918271,-1.562249379415696) circle (2.5pt);
    draw [fill=rvwvcq] (1.1000722668585952,-1.5566664708215214) circle (2.5pt);
    draw [fill=rvwvcq] (2.4001169195517105,-1.5531433145811606) circle (2.5pt);
    draw [fill=rvwvcq] (0.2994927758991701,1.4894558868736556) circle (2.5pt);
    draw [fill=rvwvcq] (1.60355056870581,0.27380879188441476) circle (2.5pt);
    end{scriptsize}
    end{tikzpicture}}
    end{document}

Though @TorbjørnT. has correctly brought out the clip factor, however when I ran the code I was not able to find any error-- you can experiment with and without the clip code to see what suits you

Answered by js bibra on August 13, 2020

The real problem here is that the bounding box of your diagram is too large. Add

draw (current bounding box.south east) rectangle (current bounding box.north west);

right before end{tikzpicture} to draw a frame along the bounding box, and you'll see this:

enter image description here

This is caused by the clip, so remove that line, and you get this:

enter image description here

If you want it a little bit higher, as in your image, remove the newline and add

baseline={([yshift=-baselineskip]current bounding box.north)}

to the options of the tikzpicture. There is no need for the additional tikz.

Finally though, are you making a list? If so, I'd recommend using a list environment, you can use the features of the enumitem package to customize the look of the list, as in this example:

documentclass[twocolumn,10pt]{article}
usepackage{enumitem} % added
usepackage{tikz}
usepackage{mathrsfs}
usetikzlibrary{arrows}
pagestyle{empty}

begin{document}
definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451}
definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
begin{enumerate}[label=textbf{arabic*)}]
item begin{tikzpicture}[scale=0.8, line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, baseline=(current bounding box.south), baseline={([yshift=-baselineskip]current bounding box.north)}]
%  clip(-5.003269918455611,-3.3529348860915125) rectangle (10.415703512539228,5.13457342454785); %% remove this line
fill[line width=2.pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] (-1.16,2.85) -- (-3.82,-1.57) -- (3.56,-1.55) -- cycle;
draw [line width=2.pt,color=rvwvcq] (-1.16,2.85)-- (-3.82,-1.57);
draw [line width=2.pt,color=rvwvcq] (-3.82,-1.57)-- (3.56,-1.55);
draw [line width=2.pt,color=rvwvcq] (3.56,-1.55)-- (-1.16,2.85);
draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-2.7200080786122416,-1.56701899208296);
draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-0.9600210043918271,-1.562249379415696);
draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (1.1000722668585952,-1.5566664708215214);
draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (2.4001169195517105,-1.5531433145811606);
draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (0.2994927758991701,1.4894558868736556);
draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (1.60355056870581,0.27380879188441476);
begin{scriptsize}
draw [fill=rvwvcq] (-1.16,2.85) circle (2.5pt);
draw [fill=rvwvcq] (-3.82,-1.57) circle (2.5pt);
draw [fill=rvwvcq] (3.56,-1.55) circle (2.5pt);
draw [fill=rvwvcq] (-2.7200080786122416,-1.56701899208296) circle (2.5pt);
draw [fill=rvwvcq] (-0.9600210043918271,-1.562249379415696) circle (2.5pt);
draw [fill=rvwvcq] (1.1000722668585952,-1.5566664708215214) circle (2.5pt);
draw [fill=rvwvcq] (2.4001169195517105,-1.5531433145811606) circle (2.5pt);
draw [fill=rvwvcq] (0.2994927758991701,1.4894558868736556) circle (2.5pt);
draw [fill=rvwvcq] (1.60355056870581,0.27380879188441476) circle (2.5pt);
end{scriptsize}

%draw (current bounding box.south east) rectangle (current bounding box.north west); % to indicate the bounding box of the diagram
end{tikzpicture}
end{enumerate}
end{document}

Answered by Torbjørn T. on August 13, 2020

The clip operation widens the bounding box of the image, by removing it, it just frames the triangle.

The 1) is written before the image code, I position it with the node operation.

node[below right] at (current bounding box.north west) {{1)}};

screenshot

documentclass[twocolumn,10pt]{article}
    usepackage{pgf,tikz,pgfplots}
    pgfplotsset{compat=1.15}
    usepackage{mathrsfs}
    usetikzlibrary{arrows}
    pagestyle{empty}
    
    
    
    
    begin{document}
    definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451}
    definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
%    textbf{1)}newline
    begin{tikzpicture}[scale=0.8, line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
%    clip(-5.003269918455611,-3.3529348860915125) rectangle (10.415703512539228,5.13457342454785);
    fill[line width=2.pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] (-1.16,2.85) -- (-3.82,-1.57) -- (3.56,-1.55) -- cycle;
    draw [line width=2.pt,color=rvwvcq] (-1.16,2.85)-- (-3.82,-1.57);
    draw [line width=2.pt,color=rvwvcq] (-3.82,-1.57)-- (3.56,-1.55);
    draw [line width=2.pt,color=rvwvcq] (3.56,-1.55)-- (-1.16,2.85);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-2.7200080786122416,-1.56701899208296);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (-0.9600210043918271,-1.562249379415696);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (1.1000722668585952,-1.5566664708215214);
    draw [line width=2.pt,color=wrwrwr] (-1.16,2.85)-- (2.4001169195517105,-1.5531433145811606);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (0.2994927758991701,1.4894558868736556);
    draw [line width=2.pt,color=wrwrwr] (-3.82,-1.57)-- (1.60355056870581,0.27380879188441476);
    begin{scriptsize}
    draw [fill=rvwvcq] (-1.16,2.85) circle (2.5pt);
    draw [fill=rvwvcq] (-3.82,-1.57) circle (2.5pt);
    draw [fill=rvwvcq] (3.56,-1.55) circle (2.5pt);
    draw [fill=rvwvcq] (-2.7200080786122416,-1.56701899208296) circle (2.5pt);
    draw [fill=rvwvcq] (-0.9600210043918271,-1.562249379415696) circle (2.5pt);
    draw [fill=rvwvcq] (1.1000722668585952,-1.5566664708215214) circle (2.5pt);
    draw [fill=rvwvcq] (2.4001169195517105,-1.5531433145811606) circle (2.5pt);
    draw [fill=rvwvcq] (0.2994927758991701,1.4894558868736556) circle (2.5pt);
    draw [fill=rvwvcq] (1.60355056870581,0.27380879188441476) circle (2.5pt);
    end{scriptsize}

    node[below right] at (current bounding box.north west) {{1)}};
    end{tikzpicture}
    end{document}

Answered by AndréC on August 13, 2020

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