在文本内对齐 tikz 图片

在文本内对齐 tikz 图片

我想在文本中对齐我的 tikz。

以下链接中的第二张图片是示例:图片由http://www.echoecho.com/htmlimages08.htm 在此处输入图片描述

这是我的试验:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=6.0em]{geometry}
\usepackage[nomessages]{fp}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{stmaryrd }
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{enumerate}
\usepackage[turkish]{babel}

\usepackage[hidelinks]{hyperref}
\usepackage[stable]{footmisc}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command

\setcounter{secnumdepth}{-1}

 \begin{document}

\begin{enumerate}
\item 
Ardışık üç pozitif tamsayının çarpımının hiçbir zaman bir tamsayının birden büyük bir kuvvetine eşit olamayacağını gösteriniz.

\item

\begin{tabular}[t]{p{4.5cm}r}

$ABCD$ kirişler dörtgeni ve $|AE|=|AD|$, $|BC|=|BE|$ dir. 
Buna göre, $EF\parallel AB$ olduğunu gösteriniz.

&


\definecolor{ffffff}{rgb}{1,1,1}
\begin{tikzpicture}[baseline=(current bounding box.north),line cap=round,line join=round,>=triangle 45,x=0.24698133918770565cm,y=0.24577572964669714cm]
\clip(-0.5,-2.72) rectangle (11.5,3.6);
\draw [line width=1.2pt] (0.06,-2.01)-- (4.43,3.26);
\draw [line width=1.2pt] (9.33,1.94)-- (4.43,3.26);
\draw [line width=1.2pt] (9.33,1.94)-- (11.14,-2.13);
\draw [line width=1.2pt] (11.14,-2.13)-- (0.06,-2.01);
\draw [line width=1.2pt] (11.14,-2.13)-- (4.43,3.26);
\draw [line width=1.2pt] (9.33,1.94)-- (0.06,-2.01);
\draw (-0.38,-2.0) node[anchor=north west] {$A$};
\draw (11.4,-2.00) node[anchor=north west] {$B$};
\draw (9.56,2.14) node[anchor=north west] {$C$};
\draw (3.96,3.48) node[anchor=north west] {$D$};
\draw (6,0.92) node[anchor=north west] {$E$};
\draw (7.90,0.87) node[anchor=north west] {$F$};
\begin{scriptsize}
\fill [color=ffffff] (0.06,-2.01) circle (2.0pt);
\fill [color=ffffff] (4.43,3.26) circle (2.0pt);
\fill [color=ffffff] (9.33,1.94) circle (2.0pt);
\fill [color=ffffff] (11.14,-2.13) circle (2.0pt);
\fill [color=ffffff] (6.36,0.67) circle (2.0pt);
\fill [color=ffffff] (7.67,0.66) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}
\end{tabular}


\item
$0<q<200$ ve $\dfrac{59}{80} < \dfrac{p}{q} <\dfrac{45}{61}$ koşullarını sağlayan bir $(p,q)$ tamsayı çifti bulunuz ve böyle tek bir $(p,q)$ tamsayı çifti olduğunu gösteriniz.

\item
$7$ arkadaşı olan bir kimse, bir hafta boyunca her akşam $3$ arkadaşını yemeğe çağırır. Farklı iki akşam yemeğe çağrılan gruplar birbirlerinden farklı olup; $7$ arkadaştan her biri en az bir akşam yemeğe çağrılmaktadır. Bu koşulları sağlayan kaç değişik çağrı programı yapılabileceğini bulunuz.

\item
\begin{tabular}[t]{p{7cm}r}

$O$ merkezli çemberin yarıçapı $R$'dir. $A$ merkezli $|AB|$ yarıçaplı çember ile $B$ merkezli $|BA|$ yarıçaplı çemberin $D$ kesim noktası alınıyor. $CD$ doğrusu, $O$ merkezli çemberi $E$ noktasında kestiğine göre $|ED|$ uzunluğunu $R$ cinsinden hesaplayınız. 

&
\begin{tikzpicture}[baseline=(current bounding box.north),line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]

\clip(-0.16,-1.88) rectangle (6.4,3.52);
\draw [line width=1.2pt] (4.02,0.3) circle (2.16cm);
\draw [line width=1.2pt] (4.55,2.4) circle (1.08cm);
\draw [line width=1.2pt] (3.47,2.39) circle (1.08cm);
\draw [line width=1.2pt] (1.93,0.87)-- (5.5,1.88);
\draw [line width=1.2pt] (1.93,0.87)-- (1.04,0.62);
\draw (4.04,0.04) node[anchor=north west] {$O$};
\draw (5.74,1.94) node[anchor=north west] {$C$};
\draw (4.78,2.58) node[anchor=north west] {$A$};
\draw (3.1,2.62) node[anchor=north west] {$B$};
\draw (1.56,1.12) node[anchor=north west] {$E$};
\draw (4.10,1.25) node[anchor=south east] {$D$};
\begin{scriptsize}
\fill [color=ffffff] (4.02,0.3) circle (2.0pt);
\fill [color=ffffff] (5.5,1.88) circle (2.0pt);
\fill [color=ffffff] (4.55,2.4) circle (2.0pt);
\fill [color=ffffff] (3.47,2.39) circle (2.0pt);
\fill [color=ffffff] (4.01,1.46) circle (2.0pt);
\fill [color=ffffff] (1.93,0.87) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

\end{tabular}

\item
$$\sqrt{x - \dfrac{1987}{14}} + \sqrt{x - \dfrac{1988}{13}} + \sqrt{x - \dfrac{1989}{12}} = \sqrt{x - \dfrac{14}{1987}} + \sqrt{x - \dfrac{13}{1988}} + \sqrt{x - \dfrac{12}{1989}}$$
denkleminin tüm reel çözümlerini bulunuz.

\item
İki kişinin bir keki paylaşmasının her iki tarafı da hoşnut eden ve adil bir yöntemi şudur: Biri keki iki parçaya ayırır, diğeri parçalardan birini kendine seçer. Diğer bir deyişle keki $[0,1]$ aralığı gibi düşünürsek, birinci kişi $x_1\in [0,1]$ seçer; ikinci kişi ise $x_1$ ve $1-x_1$ sayılarından birini seçer. (Burada her iki tarafın da ``keksever'' olduğu varsayıldığından, ikinci kişinin $x_1$ ve $1-x_1$ sayılarından daha büyük olanını seçeceği ve dolayısıyla birincinin de $x_1 = \dfrac 12$ seçimini yapacağı kolaylıkla görülür.) Üç keksever kişi için benzer bir paylaşma yöntemi bulabilir misiniz? 



\end{enumerate}

\end{document}

答案1

\usepackage[turkish]{babel}首先,无论有没有 ,您的代码都无法编译\shorthandoff{=}。现在我很难用 tikz 的代码给出答案。我认为您的代码来自 Geogebra 或类似的东西。因此,在部分 A 中,我尝试为您提供一些解释,以将 geogebra 中的代码转换为更易读、更易理解的代码。下一个代码现在很完美,因为我尝试获得一个简单且与您的代码非常相似的代码。

A 部分

你面前有一张白纸和几支铅笔。

a) 选择一支铅笔您需要选择颜色和大小。默认情况下,颜色为黑色,大小为 0.4pt。在您的代码中\definecolor{ffffff}{rgb}{1,1,1}定义一种颜色;rgb 1,1,1 是白色,这很奇怪但没有必要。Tikz 加载 xcolor 包,该包定义了一些基本颜色,如白色和黑色。如果您继续运行 Geogebra,您可以使用编辑器将所有代码(如 ffffff 更改为白色)更改为白色。举个例子\definecolor{mycolor}{rgb}{.2,1,.5}。因为尺寸line width=0.5pt在开头给出,所以这个尺寸用于绘图。line width=1.2pt对我来说太大了,但是......

b) 现在你需要画一些小圆圈。你在纸上选择一个点 (a,b),第一个点 (0,0) 就可以了。我们需要用这个点来命名这个点。你用坐标 (a) 命名。之后用同样的铅笔写下标签 $A$。使用 tikz,标签或文本可以放在节点上。默认情况下,节点是一个矩形,你在它上面写上 $A$。你可以在这里用锚点将矩形附加到点上anchor=north west

使用同一支铅笔,添加 B、C 和 D。圆圈已填充。您可以使用选项填充圆圈[fill]评论 :fill=gray例如, 如果您想要其他颜色,则默认情况下颜色为黑色。

c) 现在我们可以画线了。我们用相同的颜色和大小画出四边形,\draw (a) -- (b) -- (c) --(d) -- cycle;循环用于闭合路径

d) 点 E 和 F。F 是直线 AC 上的一个点。用重心坐标很容易定义它。我例子中的 E 位于两条直线 AC 和 BD 的交点处。我们用name path

\draw (a) -- (b) -- (c) --(d) -- cycle;
\draw [name path=ac] (a) -- (c);
\draw [name path=bd] (b) -- (d);

我得到了名称为“intersections={of=ac and bd, by=e}”的交集

您可以避免最后几步,因为 Geogebra 可以为您提供 E 和 F 的坐标,但我认为您需要使用简单坐标来放置 A、B、C 和 D。这样更易读。

图片完整代码

\begin{tikzpicture}[scale=.4,line width=0.5pt]
\draw[fill] (0,0)  coordinate (a)  circle (4pt)   node[anchor=north west] {$A$}
            (11,0) coordinate (b)  circle (4pt)   node[anchor=north west] {$B$}
            (9,3)  coordinate (c)  circle (4pt)   node[anchor=south west] {$C$} 
            (3,4) coordinate (d)   circle (4pt)   node[anchor=south west] {$D$} ;
 \draw (a) -- (b) -- (c) --(d) -- cycle;
 \draw [name path=ac] (a) -- (c);
 \draw [name path=bd] (b) -- (d);
 \draw [name intersections={of=ac and bd, by=e},fill] (e) circle (4pt) node[anchor=north] {$E$};
 \draw[fill]  (barycentric cs:a=1,c=1) coordinate (f) circle (4pt) node[anchor=north] {$F$};;
\end{tikzpicture}

评论 :我删除了baseline选项:框不相对于线放置。我也删除了x= ... and y=...。使用 x 和 y 的默认 1cm,然后使用比例,这样更简单。

B 部分

我使用picins包将图片放在文本中。你可以找到它这里

它不在 texlive 上,您需要下载它。wrapfig包与枚举列表不兼容。

您需要加载。此包很有用,因为当您使用包的\usepackage{mdwlist}宏时,缩进边距为 false,因此您需要在下一个项目之前添加\parpicpicins

\暂停{枚举} \恢复{枚举}

完整的代码可以帮助您:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=6.0em]{geometry}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{picins}
%  http://tug.ctan.org/tex-archive/macros/latex209/contrib/picins/picins.sty
\usepackage{mdwlist}
\usepackage{multicol,lipsum}
\usetikzlibrary{arrows}

\begin{document}
\begin{multicols}{2}
\begin{enumerate}

    \item 
\parpic[l]{%
\begin{tikzpicture}[scale=.25,line width=0.5pt]
\draw[fill] (0,0)  coordinate (a)  circle (4pt)   node[anchor=north west] {$A$}
            (11,0) coordinate (b)  circle (4pt)   node[anchor=north west] {$B$}
            (9,3)  coordinate (c)  circle (4pt)   node[anchor=south west] {$C$} 
            (3,4) coordinate (d)   circle (4pt)   node[anchor=south west] {$D$} ;
 \draw (a) -- (b) -- (c) --(d) -- cycle;
 \draw [name path=ac] (a) -- (c);
 \draw [name path=bd] (b) -- (d);
 \draw [name intersections={of=ac and bd, by=e},fill] (e) circle (4pt) node[anchor=north] {$E$};
 \draw[fill]  (barycentric cs:a=1,c=1) coordinate (f) circle (4pt) node[anchor=north] {$F$};;
\end{tikzpicture}
}%
\lipsum[1]
\suspend{enumerate}
\resume{enumerate}

\item   \parpic[r]{%
\begin{tikzpicture}[scale=.4,line width=0.5pt]
\draw[fill] (0,0)  coordinate (a)  circle (4pt)   node[anchor=north west] {$A$}
            (11,0) coordinate (b)  circle (4pt)   node[anchor=north west] {$B$}
            (9,3)  coordinate (c)  circle (4pt)   node[anchor=south west] {$C$} 
            (3,4) coordinate (d)   circle (4pt)   node[anchor=south west] {$D$} ;
 \draw (a) -- (b) -- (c) --(d) -- cycle;
 \draw [name path=ac] (a) -- (c);
 \draw [name path=bd] (b) -- (d);
 \draw [name intersections={of=ac and bd, by=e},fill] (e) circle (4pt) node[anchor=north] {$E$};
 \draw[fill]  (barycentric cs:a=1,c=1) coordinate (f) circle (4pt) node[anchor=north] {$F$};;
\end{tikzpicture}
}%
\lipsum[1-1]

\end{enumerate}
\end{multicols}

\begin{enumerate}

    \item 
\parpic[l]{%
\begin{tikzpicture}[scale=.8,line width=0.5pt]
\draw[fill] (0,0)  coordinate (a)  circle (4pt)   node[anchor=north west] {$A$}
            (11,0) coordinate (b)  circle (4pt)   node[anchor=north west] {$B$}
            (9,3)  coordinate (c)  circle (4pt)   node[anchor=south west] {$C$} 
            (3,4) coordinate (d)   circle (4pt)   node[anchor=south west] {$D$} ;
 \draw (a) -- (b) -- (c) --(d) -- cycle;
 \draw [name path=ac] (a) -- (c);
 \draw [name path=bd] (b) -- (d);
 \draw [name intersections={of=ac and bd, by=e},fill] (e) circle (4pt) node[anchor=north] {$E$};
 \draw[fill]  (barycentric cs:a=1,c=1) coordinate (f) circle (4pt) node[anchor=north] {$F$};;
\end{tikzpicture}
}%
\lipsum[1]
\suspend{enumerate}
\resume{enumerate}

\item   \parpic[r]{%
\begin{tikzpicture}[scale=.5,line width=0.5pt]
\draw[fill] (0,0)  coordinate (a)  circle (4pt)   node[anchor=north west] {$A$}
            (11,0) coordinate (b)  circle (4pt)   node[anchor=north west] {$B$}
            (9,3)  coordinate (c)  circle (4pt)   node[anchor=south west] {$C$} 
            (3,4) coordinate (d)   circle (4pt)   node[anchor=south west] {$D$} ;
 \draw (a) -- (b) -- (c) --(d) -- cycle;
 \draw [name path=ac] (a) -- (c);
 \draw [name path=bd] (b) -- (d);
 \draw [name intersections={of=ac and bd, by=e},fill] (e) circle (4pt) node[anchor=north] {$E$};
 \draw[fill]  (barycentric cs:a=1,c=1) coordinate (f) circle (4pt) node[anchor=north] {$F$};;
\end{tikzpicture}
}%  
\lipsum[1-1]

\end{enumerate}
\end{document}  

当我改变图片的比例时,你会看到一个小问题,圆圈变大了,这对标签来说是个问题。这就是为什么代码不完美,但我试图得到一个类似于 geogebra 的代码。

在此处输入图片描述

答案2

查看包装wrapfig(文档也可在线获取)。

相关内容