
私は tikz の使用が初めてで、図を挿入するたびに次のブロックを貼り付けます (物理学の宿題を入力しているので、描く必要がある図の種類はほぼ同じです)。
\begin{tikzpicture}[
force/.style={>=latex,draw=blue,fill=blue},
axis/.style={densely dashed,gray,font=\small},
M/.style={rectangle,draw,fill=lightgray,minimum size=0.5cm,thin},
m/.style={rectangle,draw=black,fill=lightgray,minimum size=0.3cm,thin},
plane/.style={draw=black,fill=blue!10},
string/.style={draw=red, thick},
pulley/.style={thick},
]
入力しなければならないコマンドを短くしたいと思っています。これらは「スタイル」であり、これを行う方法があることは理解していますが、tikzset を使用した試みでは混乱を招く結果しか得られませんでした。(基本的に、tikzset で記述したものが、ドキュメントの最初のページにテキストとして出力されました) ご協力いただければ幸いです。
答え1
使用\tikzset
:
\documentclass{article}
\usepackage{tikz}
\tikzset{
force/.style={>=latex,draw=blue,fill=blue},
axis/.style={densely dashed,gray,font=\small},
M/.style={rectangle,draw,fill=lightgray,minimum size=0.5cm,thin},
m/.style={rectangle,draw=black,fill=lightgray,minimum size=0.3cm,thin},
plane/.style={draw=black,fill=blue!10},
string/.style={draw=red, thick},
pulley/.style={thick},
}
\begin{document}
\begin{tikzpicture}
\draw[pulley] (0,0) -- (1,0);
% more code here
\end{tikzpicture}
\end{document}