텍스트 오른쪽에 TikZ 다이어그램 표시

텍스트 오른쪽에 TikZ 다이어그램 표시

나는 그것을 설명하는 일부 텍스트의 오른쪽에 표시할 직사각형 그림을 가지고 있습니다. 현재 직사각형은 대부분 텍스트 위(및 텍스트 오른쪽)에 있습니다. 나는 텍스트가 포함된 상자의 위쪽 가장자리에 위쪽 꼭지점을 정렬하는 것이 적절할 것이라고 생각합니다.

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}

\noindent
\begin{minipage}{4.75in}
\noindent {\textbf{1.) }}The area of a rectangle is 168 square inches, and its perimeter is 62 inches. What is the product of the magnitudes of its diagonals?
\begin{tabbing}
\hspace*{3em} \= \hspace{2.5in} \= \kill
\> {\textbf{a.) }}625   \> {\textbf{b.) }}300 \\
\> {\textbf{c.) }}200   \> {\textbf{d.) }}150 \\
\> {\textbf{e.) }}125
\end{tabbing}
\end{minipage}
\begin{tikzpicture}

%Vertices A, B, C, and D are located.
\path (0,0) coordinate (A) (20:{7/8}) coordinate (B) ($(B) +(110:3)$) coordinate (C) ($(C) +(-160:{7/8})$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D) -- cycle;

%The diagonals are drawn.
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);


%The length and width of the rectangle are typeset.
\node[anchor={20+90}, inner sep=0, font=\footnotesize] at ($($(A)!1.5mm!-90:(B)$)!0.5!($(B)!1.5mm!90:(A)$)$){$w$};
\node[anchor={110+90}, inner sep=0, font=\footnotesize] at ($($(B)!1.5mm!-90:(C)$)!0.5!($(C)!1.5mm!90:(B)$)$){$\ell$};

\end{tikzpicture}

\end{document}

답변1

미니페이지 상단을 tikzpicture 상단에 정렬하려면 다음을 사용하세요.

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}

\noindent
\begin{minipage}[t]{4.75in}
\noindent {\textbf{1.) }}The area of a rectangle is 168 square inches, and its perimeter is 62 inches. What is the product of the magnitudes of its diagonals?
\begin{tabbing}
\hspace*{3em} \= \hspace{2.5in} \= \kill
\> {\textbf{a.) }}625   \> {\textbf{b.) }}300 \\
\> {\textbf{c.) }}200   \> {\textbf{d.) }}150 \\
\> {\textbf{e.) }}125
\end{tabbing}
\end{minipage}
\begin{tikzpicture}[baseline=(current bounding box.north)]

%Vertices A, B, C, and D are located.
\path (0,0) coordinate (A) (20:{7/8}) coordinate (B) ($(B) +(110:3)$) coordinate (C) ($(C) +(-160:{7/8})$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D) -- cycle;

%The diagonals are drawn.
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);


%The length and width of the rectangle are typeset.
\node[anchor={20+90}, inner sep=0, font=\footnotesize] at ($($(A)!1.5mm!-90:(B)$)!0.5!($(B)!1.5mm!90:(A)$)$){$w$};
\node[anchor={110+90}, inner sep=0, font=\footnotesize] at ($($(B)!1.5mm!-90:(C)$)!0.5!($(C)!1.5mm!90:(B)$)$){$\ell$};

\end{tikzpicture}

\end{document}

조정


실제로, 이는 tikzpicture의 상단을 1). 1)다음과 같은 것을 추가 하려면 상단에 정렬하십시오.

\path (current bounding box.north) ++(0,-.6\baselineskip) coordinate (align);

그리고 [baseline=(align)] 을 사용할 수도 있습니다 \raisebox{0.6\baselineskip}{...}.

답변2

미니페이지에 [b] 옵션 추가

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{calc}


\begin{document}

\noindent
\begin{minipage}[b]{4.75in}
\noindent {\textbf{1.) }}The area of a rectangle is 168 square inches, and its perimeter is 62 inches. What is the product of the magnitudes of its diagonals?
\begin{tabbing}
\hspace*{3em} \= \hspace{2.5in} \= \kill
\> {\textbf{a.) }}625   \> {\textbf{b.) }}300 \\
\> {\textbf{c.) }}200   \> {\textbf{d.) }}150 \\
\> {\textbf{e.) }}125
\end{tabbing}
\end{minipage}
\begin{minipage}[b]{2in}
\begin{tikzpicture}

%Vertices A, B, C, and D are located.
\path (0,0) coordinate (A) (20:{7/8}) coordinate (B) ($(B) +(110:3)$) coordinate (C) ($(C) +(-160:{7/8})$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D) -- cycle;

%The diagonals are drawn.
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);


%The length and width of the rectangle are typeset.
\node[anchor={20+90}, inner sep=0, font=\footnotesize] at ($($(A)!1.5mm!-90:(B)$)!0.5!($(B)!1.5mm!90:(A)$)$){$w$};
\node[anchor={110+90}, inner sep=0, font=\footnotesize] at ($($(B)!1.5mm!-90:(C)$)!0.5!($(C)!1.5mm!90:(B)$)$){$\ell$};

\end{tikzpicture}
\end{minipage}

\end{document}

사실 저는 미니페이지가 포함된 이러한 레이아웃을 좋아하지 않으므로 노드 위치를 조정하여 tikz로 직접 이 작업을 수행합니다.

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{calc,positioning}

\begin{document}


\begin{tikzpicture}
\node(fig){\begin{tikzpicture}
%Vertices A, B, C, and D are located.
\path (0,0) coordinate (A) (20:{7/8}) coordinate (B) ($(B) +(110:3)$) coordinate (C) ($(C) +(-160:{7/8})$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D) -- cycle;

%The diagonals are drawn.
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);


%The length and width of the rectangle are typeset.
\node[anchor={20+90}, inner sep=0, font=\footnotesize] at ($($(A)!1.5mm!-90:(B)$)!0.5!($(B)!1.5mm!90:(A)$)$){$w$};
\node[anchor={110+90}, inner sep=0, font=\footnotesize] at ($($(B)!1.5mm!-90:(C)$)!0.5!($(C)!1.5mm!90:(B)$)$){$\ell$};

\end{tikzpicture}};
\node[below left =0em of fig.north west, text width=4.75in]{
\noindent {\textbf{1.) }}The area of a rectangle is 168 square inches, and its perimeter is 62 inches. What is the product of the magnitudes of its diagonals?
\begin{tabbing}
\hspace*{3em} \= \hspace{2.5in} \= \kill
\> {\textbf{a.) }}625   \> {\textbf{b.) }}300 \\
\> {\textbf{c.) }}200   \> {\textbf{d.) }}150 \\
\> {\textbf{e.) }}125
\end{tabbing}
};
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보