我怎样才能在年级段中更改此段?我附上了图
这是我的代码:
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{arrows,arrows.meta}
\pagestyle{empty}
\newcommand{\degre}{\ensuremath{^\circ}}
% \renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}
\usepackage{sansmath}
\definecolor{uququq}{rgb}{0.25098039215686274,0.25098039215686274,0.25098039215686274}
\tikzset{
quote/.style={{|[width=2mm]}-{|[width=2mm]}}
}
\begin{document}
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (1,2);
\coordinate (b) at (7,2);
\draw[black,step=1cm] (0,0) grid +(15cm,4cm);
\draw[ultra thick, line width=1.25mm, black, |-|] (a) -- (b);
\draw[color=black] (0.5, 1.5) node {\Huge $A$};
\draw[color=black] (7.5, 1.5) node {\Huge $B$};
\end{tikzpicture}
\end{document}
答案1
ticks
图书馆的装饰decorations.pathreplacing
是一种方式。另外,你可以设计自己的图书馆装饰decorations.markings
。
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\pagecolor{yellow!30}
\begin{document}
\begin{tikzpicture}
\draw[lightgray] (-1,-1) grid (5,4);
\path (4,0) coordinate (A) node[below right]{$A$};
\path (0,3) coordinate (B) node[above left]{$B$};
\draw[ultra thick] (A) -- (B);
\draw[ultra thick, decoration={ticks,amplitude=4pt,
segment length=1cm},decorate,red] (A) -- (B);
\end{tikzpicture}
\usetikzlibrary{decorations.markings}
\begin{tikzpicture}[decoration={
markings,% switch on markings
mark=% actually add a mark
between positions 0 and 1 step 1cm
with {
\fill[blue] (0,0) circle(3pt);
%\draw[red] (0,-2pt)--(0,2pt); // try if you want ticks
}}]
\draw[lightgray] (-1,-1) grid (5,4);
\draw[postaction={decorate}] (4,0)--(0,3)|-cycle;
\end{tikzpicture}
\end{document}
答案2
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{arrows,arrows.meta}
\usetikzlibrary{decorations.pathreplacing}
\pagestyle{empty}
\newcommand{\degre}{\ensuremath{^\circ}}
% \renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}
\usepackage{sansmath}
\definecolor{uququq}{rgb}{0.25098039215686274,0.25098039215686274,0.25098039215686274}
\tikzset{
quote/.style={{|[width=2mm]}-{|[width=2mm]}}
}
\begin{document}
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (1,2);
\coordinate (b) at (7,2);
\draw[black,step=1cm] (0,0) grid +(15cm,4cm);
\draw[ultra thick, line width=1.25mm, black, |-|] (a) -- (b);
\draw[ultra thick, decoration={ticks,amplitude=8pt,
segment length=1cm},decorate] (a) -- (b);
\draw[color=black] (0.5, 1.5) node {\Huge $A$};
\draw[color=black] (7.5, 1.5) node {\Huge $B$};
\end{tikzpicture}
\end{document}