見出し画像

TikZ作品集「内分・外分を読み取る」の図

与えられた3点から内分点・外分点を読み取る問題を、読んで理解してもらえるよう図を作りました。バックアップがてらTeXソースを貼っておきます。CloudLaTeXに貼り付けるだけでコンパイルが通ると思います。よろしかったらどうぞ。

ソースコード

\documentclass[dvipdfmx,border=2mm,multi=pageSplit]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}% 計算
\usepackage{emath}
\usepackage{ifthen}

\definecolor{mistyrose}{rgb}{1.0, 0.89, 0.88}
\definecolor{lightcyan}{rgb}{0.88, 1.0, 1.0}
\definecolor{bisque}{rgb}{1.0, 0.89, 0.77}
\definecolor{palegreen}{rgb}{0.59,0.98,0.59}

\begin{document}
\begin{pageSplit}
\begin{tikzpicture}[scale=1.0]

%% 問題設定(3点を設定する)
\def\tMain{C}\def\vMain{3}  %分点の名前・座標
\def\tSubL{A}\def\vSubL{1}  %線分始点の名前・座標
\def\tSubR{B}\def\vSubR{7}  %線分終点の名前・座標
\def\Min{-0.5}  %数直線の最小値
\def\Max{8.5}   %数直線の最大値









%% 作業①描画
\def\Base{7}%作業①の基本y座標
\coordinate (Main) at (\vMain,\Base);  %%分点
\coordinate (SubL) at (\vSubL,\Base);  %%線分始点
\coordinate (SubR) at (\vSubR,\Base);  %%線分終点
\coordinate (Msg) at ($(\Min,\Base)+(0,0.5)$);  %%①テキスト位置
\ifthenelse{\vSubL < \vMain \AND \vMain < \vSubR}{
  \def\Naigai{内側}
  \def\Bunten{内分}
}{
  \ifthenelse{\vSubR < \vMain \AND \vMain < \vSubL}{
    \def\Naigai{内側}
    \def\Bunten{内分}
  }{
    \def\Naigai{外側}
    \def\Bunten{外分}
  }
}
\draw (Msg) node[right,yshift=2zw] {\colorbox{mistyrose}{\gtfamily\maru1\ \tMain\ は\ \colorbox{mistyrose!90!red}{\tSubL\tSubR}\ の \Naigai{} $\Rightarrow$ \Bunten{}点}};%%①テキスト
\draw[->,>=stealth,line width=8pt,mistyrose!90!red] (SubL)--(SubR);%%線分を色付け
\draw[->,>=stealth, thick] (\Min,\Base)--(\Max,\Base) node [below,yshift=-2pt] {$x$};%%x軸を描画
\draw ([yshift=2pt] Main) node [above] {\colorbox{mistyrose}{\tMain}};
\draw ([yshift=3pt] Main)--([yshift=-3pt] Main) node [below] {\vMain};
\draw ([yshift=2pt] SubL) node [above] {\colorbox{bisque}{\tSubL}};
\draw ([yshift=3pt] SubL)--([yshift=-3pt] SubL) node [below] {$\vSubL$};
\draw ([yshift=2pt] SubR) node [above] {\colorbox{palegreen}{\tSubR}};
\draw ([yshift=3pt] SubR)--([yshift=-3pt] SubR) node [below] {$\vSubR$};




%% 作業②描画
\def\Base{4}%%作業②の基本y座標  
\coordinate (Main) at (\vMain,\Base);  %%分点
\coordinate (SubL) at (\vSubL,\Base);  %%線分始点
\coordinate (SubR) at (\vSubR,\Base);  %%線分終点
\coordinate (Msg) at ($(\Min,\Base)+(0,0.5)$);  %%②テキスト位置
\draw (Msg) node[right,yshift=2zw] {\colorbox{bisque}{\gtfamily\maru2\ 線分の始点\ \tSubL\ と\ \tMain\ の距離 $\Rightarrow m$}};%%②テキスト
\draw[->,>=stealth, thick] (\Min,\Base)--(\Max,\Base) node [below,yshift=-2pt] {$x$};%%x軸を描画
\draw ([yshift=2pt] Main) node [above] {\colorbox{mistyrose}{\tMain}};
\draw ([yshift=2pt] Main)--([yshift=-2pt] Main) node [below] {\vMain};
\draw ([yshift=2pt] SubL) node [above] {\colorbox{bisque}{\tSubL}};
\draw ([yshift=2pt] SubL)--([yshift=-2pt] SubL) node [below] {$\vSubL$};
\draw ([yshift=2pt] SubR) node [above] {\tSubR};
\draw ([yshift=2pt] SubR)--([yshift=-2pt] SubR) node [below] {$\vSubR$};
\ifthenelse{\vMain > \vSubL}{
  \def\direction{bend right}
}{
  \def\direction{bend left}
}
\draw[orange,->,>=stealth,line width=3pt] ([yshift=-1.5zw] SubL) to [\direction]  node [midway,below] {\colorbox{bisque}{$m$}} ([yshift=-1.5zw] Main);





%% 作業③描画
\def\Base{0.5}%%作業③の基本y座標
\coordinate (Main) at (\vMain,\Base);  %%分点
\coordinate (SubL) at (\vSubL,\Base);  %%線分始点
\coordinate (SubR) at (\vSubR,\Base);  %%線分終点
\coordinate (Msg) at ($(\Min,\Base)+(0,0.5)$);  %%③テキスト位置
\draw (Msg) node[right,yshift=2zw] {\colorbox{palegreen}{\gtfamily\maru3\ \tMain\ と\ 線分の終点\ \tSubR\ の距離 $\Rightarrow n$}};
\draw[->,>=stealth, thick] (\Min,\Base)--(\Max,\Base) node [below,yshift=-2pt] {$x$};%%x軸を描画


\draw ([yshift=2pt] Main) node [above] {\colorbox{mistyrose}{\tMain}};
\draw ([yshift=2pt] Main)--([yshift=-2pt] Main) node [below] {\vMain};
\draw ([yshift=2pt] SubL) node [above] {\tSubL};
\draw ([yshift=2pt] SubL)--([yshift=-2pt] SubL) node [below] {$\vSubL$};
\draw ([yshift=2pt] SubR) node [above] {\colorbox{palegreen}{\tSubR}};
\draw ([yshift=2pt] SubR)--([yshift=-2pt] SubR) node [below] {$\vSubR$};
\ifthenelse{\vMain < \vSubR}{
  \def\direction{bend right}
}{
  \def\direction{bend left}
}
\draw[green!70!black,->,>=stealth,line width=3pt] ([yshift=-1.5zw] Main) to [\direction]  node [green!60!black,midway,below] {\colorbox{palegreen}{$n$}} ([yshift=-1.5zw] SubR);


\end{tikzpicture}
\end{pageSplit}
\end{document}

サンプルはこちら


この記事が気に入ったらサポートをしてみませんか?