![다른 방향의 그래프](https://rvso.com/image/298811/%EB%8B%A4%EB%A5%B8%20%EB%B0%A9%ED%96%A5%EC%9D%98%20%EA%B7%B8%EB%9E%98%ED%94%84.png)
위 그림과 비슷한 그래프를 만들어야 하는데 화살표나 수직 화살표 없이 수평선을 그리는 방법을 모르겠습니다. 내가 할 수 있는 최선은 다음과 같습니다.
\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node (p1) at ( 0, 0) {};
\node (p2) at ( 1, -0.2) {i};
\node (p3) at ( 3,0) {};
\node (p4) at ( 0,1) {};
\node (p5) at ( 2,1.2) {n+j};
\node (p6) at ( 3,1) {};
\begin{scope}[every path/.style={->}]
\draw (p1) -- (p3);
\draw (p4) -- (p6);
\draw (p2) -- (p5);
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}
산출
답변1
이것이 원하는 결과입니까?
노트:
- 줄 끝에 화살표가 표시되는 것을 원하지 않으면 스타일을 변경하거나
every path/.style={-}
아래에서 설명한 대로 해당 옵션을 제거하세요. 선에는 기본적으로 화살촉이 표시되지 않습니다. - 원하는 화살표 스타일은 입니다
-latex
. 따라서 필요할 때 해당 옵션을 추가하기만 하면 됩니다(주황색 선의 경우와 마찬가지로). - 주황색 선을 연장하기 위해
shorten <=
및 를 추가했습니다 .shorten >=
또는 다음과 같은 점을 수동으로 선택할 수도 있습니다.~에라인. - 라이브러리 는 검은색 수직선이 그려지는
calc
중간 s를 계산하는 데 사용되었습니다 .coordinate
- .
$
- 어떤 그리기 명령이 무엇을 하는지 더 쉽게 알 수 있도록 색상이 추가되었습니다.
암호:
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}[thick]
\node (p1) at ( 0, 0) {};
\node (p2) at ( 1, -0.2) {$i$};
\node (p3) at ( 3,0) {};
\node (p4) at ( 0,1) {};
\node (p5) at ( 2,1.2) {$n+j$};
\node (p6) at ( 3,1) {};
\coordinate (p1MidwayP3) at ($(p1)!0.5!(p3)$);
\coordinate (p4MidwayP6) at ($(p4)!0.5!(p6)$);
\begin{scope}%[every path/.style={-}]
\draw [red] (p1) -- (p3);
\draw [blue] (p4) -- (p6);
\draw [orange, shorten <=-0.08cm, shorten >=-0.10cm, -latex](p2) -- (p5);
\draw (p1MidwayP3) -- (p4MidwayP6);
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}
답변2
다음과 결합된 PSTricks 솔루션xfp
:
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{xfp}
\begin{document}
\def\Horizontal{5} % length of the horizontal line segments
\def\Vertical{3} % length of the vertical line segment
\def\Indent{0.5} % indentation of the arrow from both sides
\begin{pspicture}(0,-0.4)(\Horizontal,\fpeval{\Vertical+0.45})
\psline(0,0)(\Horizontal,0)
\psline(0,\Vertical)(\Horizontal,\Vertical)
\psline(\fpeval{\Horizontal/2},0)(\fpeval{\Horizontal/2},\Vertical)
\psline{->}(\Indent,0)(\fpeval{\Horizontal-\Indent},\Vertical)
\uput[270](\Indent,0){$i$}
\uput[90](\fpeval{\Horizontal-\Indent},\Vertical){$n+j$}
\end{pspicture}
\end{document}
\Horizontal
, \Vertical
및 값을 선택하기만 하면 \Indent
그에 따라 도면이 조정됩니다.