tikz 的问题

tikz 的问题

我需要做这张照片...

在此处输入图片描述

这是我的起始代码。我该如何绘制角度?以及虚线?谢谢!

\documentclass[a4paper,12pt]{article}[12pt] 



\usepackage{xcolor}

\usepackage{tikz}



\linespread{1.5}                    %spessore interlinea (default=1, MM1 = s1.4)



\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}



  \usepackage[a4paper,top=1.3cm,bottom=1.3cm,left=1.5cm,right=1.5cm]{geometry}

  \usepackage{enumerate}

   \usepackage{multicol}

   \usepackage{textgreek}



\begin{document}



\begin{enumerate}


\item 


\begin{minipage}[t][][b] {6cm}
\end{minipage}%
\begin{minipage}[t][][b] {9cm}
\begin{tikzpicture}[> = stealth]
\draw[gray,step=1cm] (0,0) grid +(15cm,15cm);
    \draw[ultra thick,red]  (4,5) -- node[above] {} +(2,2);
  \draw[ultra thick,red]  (4,5) -- node[above] {} +(-1,2);
  %\draw[ultra thick,red]  (4,5) -- node[above] {} +(0,-3);
%  \draw[ultra thick,black]  (4,5) -- node[above] {} +(+3,0);
%  \draw[ultra thick,black]  (4,5) -- node[above] {} +(-3,0);




     \draw[ultra thick,black]  (9,8) -- node[above] {} +(+3,0);
      \draw[ultra thick,black]  (9,8) -- node[above] {} +(0,6);
       \draw[ultra thick,black]  (9,8) -- node[above] {} +(3,6);
%        \draw[ultra thick,black]  (9,14) -- node[above] {} +(3,0);
%         \draw[ultra thick,black]  (12,14) -- node[above] {} +(0,-6);




\end{tikzpicture}
\end{minipage}


%\item Determina le componenti in direzione orizzontale e verticale del vettore $ \vec{r} $, sapendo che: 
%
%%$ \abs{\vec{r}}= {r}= $ 5 e $ \alpha= $ 60°. 
%
%
%\begin{minipage}[t][][b] {6cm}
%   \begin{itemize}
%\item $ \abs{\vec{r}}= {r}= $ 5;
%\item $ \alpha= $ 60°.
%    \end{itemize}
%\end{minipage}%
%\begin{minipage}[t][][b] {9cm}
%\begin{tikzpicture}[> = stealth]
%%\coordinate (a) at (1,4);
%%\coordinate (b) at (3,5);
%%\coordinate (c) at (5,4);
%\coordinate (d) at (1,1);
%\coordinate (e) at (2,2.866025);
%%
%%
%%
%%\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
%%
%%\draw [fill=green!30] (a) -- ++(1cm,0) arc(0:{atan(1/2)}:1cm) node[pos=1.2,right, above] {$\alpha$} -- cycle;
%%
%
%\draw [fill=green!30] (d) -- ++(0.5cm,0) arc(0:{atan(0.57735)}:0.5cm) node[pos=1.5,right, above]  {\Large $\alpha$} -- cycle;
%
%
%
%%\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
%%\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
%\draw[ultra thick,red, ->]  (d) -- node[above left] {\Large $\vec{r}$} (e);
%\end{tikzpicture}
%\end{minipage}





%
%
%
%
%
%
%
%
%
%
%\item Determina le componenti in direzione orizzontale e verticale del vettore $ \vec{r} $, sapendo che: 
%
%%$ \abs{\vec{r}}= {r}= $ 5 e $ \alpha= $ 60°. 
%
%
%\begin{minipage}[t][][b] {6cm}
%   \begin{itemize}
%\item $ \abs{\vec{r}}= {r}= $ 5;
%\item $ \alpha= $ 60°.
%    \end{itemize}
%\end{minipage}%
%\begin{minipage}[t][][b] {9cm}
%\begin{tikzpicture}[> = stealth]
%%\coordinate (a) at (1,4);
%%\coordinate (b) at (3,5);
%%\coordinate (c) at (5,4);
%\coordinate (d) at (1,1);
%\coordinate (e) at (2,2.866025);
%%
%%
%%
%%\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
%%
%%\draw [fill=green!30] (a) -- ++(1cm,0) arc(0:{atan(1/2)}:1cm) node[pos=1.2,right, above] {$\alpha$} -- cycle;
%%
%
%\draw [fill=green!30] (d) -- ++(0.5cm,0) arc(0:{atan(0.57735)}:0.5cm) node[pos=1.5,right, above]  {\Large $\alpha$} -- cycle;
%
%
%
%%\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
%%\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
%\draw[ultra thick,red,]  (d) -- node[above left] {\Large {r}} (e);
%\end{tikzpicture}
%\end{minipage}
%
%
%
%
%
%
%
%
%
%
%
%
%% Table generated by Excel2LaTeX from sheet 'Foglio1'
%\begin{table}[htbp]
%  \centering
%  %\caption{Add caption}
%    \begin{tabular}{rcccccc}
%    \toprule
%    \textbf{Esercizio} & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4}  & \textbf{TOT} \\
%    \midrule
%    \textbf{Punti} & 
%    \dots\dots/1.25 & 
%    \dots\dots/0.75 & 
%    \dots\dots/0.75 & 
%    \dots\dots/1.25 & 
%    \dots\dots/4.0 \\
%    \bottomrule
%    \end{tabular}%
%  %\label{tab:addlabel}%
%  \caption*{Punteggio minimo: 2/10 \qquad Punteggio per la sufficienza:  2.6/ 4.0}
%\end{table}%

答案1

这里提供了一个带有软件包的替代解决方案tkz-euclide,只是为了完整性。

输出

图片

代码

\documentclass[a4paper]{article}
\usepackage{lipsum} % for the example, safe to remove
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\lipsum[1] % replaces text

\begin{figure}[!htb]
\centering
\begin{minipage}{.45\textwidth}
\centering
    \begin{tikzpicture}
    \tkzDefPoint(-2,0){L}
    \tkzDefPoint(-1,2){A}
    \tkzDefPoint(0,0){O}
    \tkzDefPoint(0,3){U}
    \tkzDefPoint(1,2){B}
    \tkzDefPoint(2,0){R}
    \tkzDefPoint(2,3){Y} 

    \tkzMarkAngle[draw=red!40, fill=red!40](R,O,L)
        \tkzLabelAngle[pos=1.2, color=red!40](A,O,L){$\alpha$}
        \tkzLabelAngle[pos=1.2, color=red!40](R,O,B){$\alpha$}
    \tkzMarkAngle[draw=blue!60, fill=blue!60](B,O,A)
        \tkzLabelAngle[pos=1.2, color=blue!60](U,O,A){$\beta$}
        \tkzLabelAngle[pos=1.2, color=blue!60](U,O,B){$\beta$}

    \tkzDrawSegments[thin, loosely dashed](L,R O,U A,B)
    \tkzDrawSegments[ultra thick](A,O O,B)

    \end{tikzpicture}
    \caption{image 1}
\end{minipage}
\begin{minipage}{.45\textwidth}
\centering
    \begin{tikzpicture}

    \tkzMarkAngle[draw=red!40, fill=red!40](Y,O,U)
        \tkzLabelAngle[pos=1.2, color=red!40](Y,O,U){$\gamma$}
    \tkzMarkAngle[draw=blue!60, fill=blue!60](R,O,Y)
        \tkzLabelAngle[pos=1.2, color=blue!60](R,O,Y){$\alpha$}

    \tkzDrawSegments(R,O O,U)
    \tkzDrawSegments[loosely dashed](U,Y Y,R)
    \tkzDrawSegment[ultra thick, arrows=->](O,Y)

    \end{tikzpicture}
    \caption{image 2}
\end{minipage}
\end{figure}

\lipsum[2] % replaces text
\end{document}

答案2

不幸的是你的 MWE 无法编译...所以我从中制作了自己的:

编辑:为了生成更紧凑的角度表示并展示对角度标签位置的可能控制angle eccentricity,我稍微改变了原始答案(删除所有未使用的包,将两张图片移动到一行中):

\documentclass[a4paper,12pt]{article}
    \usepackage{xcolor}
    \usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}
    \usepackage[a4paper,top=1.3cm,bottom=1.3cm,left=1.5cm,right=1.5cm]{geometry}

    \begin{document}
    \begin{tikzpicture}[
              > = stealth,
   angle radius = 12mm,
my angle/.style = {draw, fill=#1,
                   angle eccentricity=1.2} % angle label position!
                       ]
\draw[gray,step=1cm] (0,0) grid +(15cm,7cm);
\coordinate (A0) at ( 9,1);
    \node   (Ay) at ( 9,7) [above] {$y$};
    \node   (Ax) at (12,1) [right] {$x$};
\coordinate (A)  at (12,7);

\path   (A0) edge[thick,->]     (Ax)
        (A0) edge[thick,->]     (Ay)
        (A0) edge[ultra thick]  (A)
pic [my angle=blue!30, "$\beta$"] {angle = Ax--A0--A}
pic [my angle=red!30, "$\gamma$"] {angle = A--A0--Ay};
\draw[dashed] (Ay.south) -| (Ax.west);
%
\coordinate (B0) at (4,4);
    \node   (By) at (4,6) [above] {$y$};
\coordinate (Bx1)at (2,4);
    \node   (Bx2)at (6,4) [right] {$x$};
\coordinate (B1) at (2,6);
\coordinate (B2) at (6,6);

\path   (Bx1) edge[thick,->]     (Bx2)
        (B0)  edge[thick,->]     (By)
        (B0)  edge[ultra thick]  (B1)
        (B0)  edge[ultra thick]  (B2)
pic [my angle=red!30, "$\alpha$"]    {angle = Bx2--B0--B2}
pic [my angle=blue!30, "$\beta$"]    {angle = B2--B0--By}
pic [my angle=blue!30, "$\beta$"]    {angle = By--B0--B1}
pic [my angle=red!30, "$\alpha$"]    {angle = B1--B0--Bx1};
    \end{tikzpicture}
    \end{document}

我希望我没有遗漏对您来说至关重要的内容。您可以轻松添加枚举、迷你页面等。此外,要更改图片位置,您只需要适当更改/重新计算图片坐标即可。

如您所见,对于角度,我使用小图片pic。为了使用它们,我添加了两个包:anglesquotes

在此处输入图片描述

相关内容