
Я пытаюсь сделать так, чтобы две линии пересекались с помощью синтаксиса (intersection cs: first line={}, second line={})
. Однако компиляция следующего примера не делает то, что я хочу:
%!TEX encoding = UTF-8 Unicode
%!TEX program = lualatex
\documentclass[11pt,a4paper,fleqn,pdftex]{report}
\usepackage[dvipsnames, table]{xcolor}
\usepackage[utf8]{luainputenc}
\usepackage[latin,english]{babel}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (S) at (-5 ,0);
\coordinate (M'1) at (0,4.5);
\coordinate (M2) at (0,3);
\def\angleM{10}
\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5) -- (5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4) -- (45:4)}) circle (2pt) -- (S); % (S) -> (M2)
\draw (S) node[ellipse, fill=white, minimum height=3cm,minimum width=2mm,draw]{$(S)$};
\begin{scope}[thick]
\draw[densely dashed] (M'1) ++(1,0) -- ++(-2,0) node[left]{$M'_1$};
\draw (M2) ++(1,0) -- ++(-2,0) node[left]{$M_2$};
\end{scope}
\fill[pattern=north east lines] (M'1) ++(1,0) rectangle ++(-2,0.2);
\fill[pattern=north east lines] (M2) ++(1,0) rectangle ++(-2,0.2);
\draw[very thick] (45:-2) -- (45:2);
\end{tikzpicture}
\end{figure}
\end{document}
Этот код выдает следующее:
А я хочу, чтобы красные линии пересекались с черной линией в центре. Что-то я делаю не так? В руководстве PGF/TikZ нет ни одного примера синтаксиса пересечения с относительными путями.
решение1
Не оставляйте пробелов в спецификации линий в intersection
системе координат: вместо
\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5) -- (5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4) -- (45:4)}) circle (2pt) -- (S); % (S) -> (M2)
вам следует использовать
\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5)--(5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4)--(45:4)}) circle (2pt) -- (S); % (S) -> (M2)
(чтобы сделать объяснение более понятным, у вас было second line={(-5,-5) -- (5,5)}
с пробелами по обеим сторонам --
, а должно быть second line={(-5,-5)--(5,5)})
без пробелов; аналогичное замечание для другого \draw
.
Код:
%!TEX encoding = UTF-8 Unicode
%!TEX program = lualatex
\documentclass[11pt,a4paper,fleqn,pdftex]{report}
\usepackage[dvipsnames, table]{xcolor}
\usepackage[utf8]{luainputenc}
\usepackage[latin,english]{babel}
\usepackage{tikz}
\usetikzlibrary{patterns,calc}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (S) at (-5 ,0);
\coordinate (M'1) at (0,4.5);
\coordinate (M2) at (0,3);
\def\angleM{10}
\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5)--(5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4)--(45:4)}) circle (2pt) -- (S); % (S) -> (M2)
\draw (S) node[ellipse, fill=white, minimum height=3cm,minimum width=2mm,draw]{$(S)$};
\begin{scope}[thick]
\draw[densely dashed] (M'1) ++(1,0) -- ++(-2,0) node[left]{$M'_1$};
\draw (M2) ++(1,0) -- ++(-2,0) node[left]{$M_2$};
\end{scope}
\fill[pattern=north east lines] (M'1) ++(1,0) rectangle ++(-2,0.2);
\fill[pattern=north east lines] (M2) ++(1,0) rectangle ++(-2,0.2);
\draw[very thick] (45:-2) -- (45:2);
\coordinate (L) at ( $ (80 :-8) + (0,4.5) $ );
\end{tikzpicture}
\end{figure}
\end{document}
На самом деле, вы можете оставить пробел перед, --
но не после! Возможно, это можно считать ошибкой?