在框架中,此代码不起作用。我知道(因为我试过)这是 \foreach,但我不知道为什么。我也知道这是 beamer 的问题(此代码在另一个文档中有效):
\begin{center}
\begin{tikzpicture}[scale=.8]
\draw (0,0)--(10,0)--(10,2)--(0,2)--(0,0);
\foreach \x in {1,2,3,4,5,6,7,8,9} \draw (\x,1) circle(.25);
\draw [dashed] (5,2.25)--(5,-0.25) node[below] {$\Delta$};
%force1
\def\x{1}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,-1) node[midway,right] {$\overrightarrow{F_1}$};
\draw[dashed,<->] (\x,2.25)--(5,2.25) node[midway,above] {$d_1$};
%force2
\def\x{3}
\def\y{-2}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,\y) node[midway,right] {$\overrightarrow{F_2}$};
\draw[dashed,<->] (\x,-2.25)--(5,-2.25) node[midway,above] {$d_2$};
%force3
\def\x{8}
\def\y{-3}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,\y) node[midway,right] {$\overrightarrow{F_3}$};
\draw[dashed,<->] (\x,2.25)--(5,2.25) node[midway,above] {$d_3$};
%sens
\draw[thick,->] (-1,2) arc (180:200:2.5) node[below] {$+$};
\end{tikzpicture}
\end{center}
感谢您的帮助,
这里是完整的代码(取消注释 \foreach 会出现错误)
\documentclass[10pt]{beamer}
\usetheme{Warsaw}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{gensymb}
\usepackage{animate}
\usepackage{graphicx}
\usepackage{xmpmulti}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage[tikz]{bclogo}
\usepackage[miktex]{gnuplottex}
\usepackage{pgfplots}
\usepackage{chemmacros}
\usepackage{smartdiagram}
\usepackage[compatibility,european,cuteinductors]{circuitikz}
\usepackage{pgf}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{positioning}
\usetikzlibrary{babel}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{backgrounds,shadows,fit}
\usetikzlibrary{decorations.markings,decorations.pathmorphing,decorations.pathreplacing}
\usetikzlibrary{calc,patterns,shapes.geometric}
\tikzset{circuit declare symbol = AC voltmeter}
\tikzset{set AC voltmeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center :{$\underset{\sim}{V}$}}}
\tikzset{circuit declare symbol = ammeter}
\tikzset{set ammeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:A}}
%\title{}
%\setbeamercovered{transparent}
%\setbeamertemplate{navigation symbols}{}
%\logo{}
%\institute{}
\date{2020-2021}
%\subject{}
\title{Obtenir l'équilibre d'un solide en rotation}
\begin{document}
\maketitle
\begin{frame}{Équilibre d'un solide en rotation autour d'un axe}
Un solide mobile d'un axe fixe est en équilibre si la somme des moments des forces appliqués au solide est nulle :
\begin{center}
\begin{tikzpicture}[scale=.75]
%
\draw (0,0)--(10,0)--(10,2)--(0,2)--(0,0);
%
%
%
%\foreach \x in {1,2,3,4,5,6,7,8,9} \draw (\x,1) circle(.25);
\draw [dashed] (5,2.25)--(5,-0.25) node[below] {$\Delta$};
%force1
\def\x{1}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,-1) node[midway,right] {$\overrightarrow{F_1}$};
\draw[dashed,<->] (\x,2.25)--(5,2.25) node[midway,above] {$d_1$};
%force2
\def\x{3}
\def\y{-2}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,\y) node[midway,right] {$\overrightarrow{F_2}$};
\draw[dashed,<->] (\x,-2.25)--(5,-2.25) node[midway,above] {$d_2$};
%force3
\def\x{8}
\def\y{-3}
\filldraw[gray!20] (\x,1) circle (.25) ;
\draw[thick,->] (\x,1)--(\x,\y) node[midway,right] {$\overrightarrow{F_3}$};
\draw[dashed,<->] (\x,2.25)--(5,2.25) node[midway,above] {$d_3$};
%sens
\draw[thick,->] (-1,2) arc (180:200:2.5) node[below] {$+$};
%distance
\end{tikzpicture}
\end{center}
Il va falloir procéder par ordre : repérer les forces, calculer les moments, écrire la somme en faisant attention au signe (\og dans quel sens la force ferait tourner le mobile \fg{})
\end{frame}
\end{document}