【问题标题】:LaTeX beamer slide with symbols of people带有人物符号的 LaTeX 投影仪幻灯片
【发布时间】:2019-06-05 02:48:24
【问题描述】:

我正在使用 LaTeX 制作演示幻灯片,我想制作一张幻灯片来展示处于一定水平的学生。基本上我想用人的符号填充乳胶幻灯片,如下图所示:

我想输入蓝色人的行/列数以及蓝色和红色人的数量。

请帮帮我!我什至不知道从哪里开始。

【问题讨论】:

    标签: latex beamer


    【解决方案1】:

    您已经从crosspost(您在问题中没有提到)知道如何用 tikz 形状填充幻灯片。对于其他一些可能使用的形状,这里有一些建议:

    使用tikzpeople 包,可以执行以下操作:

    \documentclass{beamer}
    
    \usepackage{tikz}
    \usepackage{tikzpeople}
    
    \begin{document}
    \begin{frame}
    
    \foreach \x in {0,1,...,17}{\tikz{\node[person,shirt=red,scale=2] (B) at (0,0) {};} }%
    \foreach \x in {0,1,...,10}{\tikz{\node[person,shirt=blue,scale=2] (B) at (0,0) {};} }
    
    \end{frame}
    \end{document}
    

    而且比人还厉害的是鸭子:

    \documentclass{beamer}
    \usepackage{tikzducks}
    
    \begin{document}
    \begin{frame}
    
    \foreach \x in {0,1,...,17}{\tikz{\duck[body=red,scale=0.5];} }%
    \foreach \x in {0,1,...,10}{\tikz{\duck[body=blue,scale=0.5];} }
    
    \end{frame}
    \end{document}
    

    或者泰迪熊:

    \documentclass{beamer}
    \usepackage{tikzlings}
    
    \begin{document}
    \begin{frame}
    
    \foreach \x in {0,1,...,17}{\tikz{\bear[body=red,scale=0.5];} }%
    \foreach \x in {0,1,...,10}{\tikz{\bear[body=blue,scale=0.5];} }
    
    \end{frame}
    \end{document}
    

    【讨论】:

    • 这太好了,但是在 Overleaf 中找不到这些包,我什至尝试手动加载 .sty 文件。你对此有什么建议吗?/
    • @bvowe 向背页投诉,他们的 texlive 版本已经过时了。如果有足够多的人抱怨,也许他们最终会更新。
    • 好的,谢谢。您是否知道实现它们的另一种方法,或者我应该将其作为新问题发布?
    • @bvowe 作为奖励:如果您说服他们使用最新的 texlive 安装,您的投影仪编号问题可以在一行中解决。
    • @bvowe 上传 .sty 似乎可行:overleaf.com/read/rkvyhtbsjhrt
    【解决方案2】:

    Tikz 提供所需的一切:循环和数学评估。
    这是一个建议。假设您的红色/蓝色形状分别位于 red.pdf 和 blue.pdf 中。我已将其替换为 red.pdf 和 blue.pdf 文件中的红色和蓝色方块。

    \documentclass{article}
    \usepackage{tikz}
    \usepackage{graphicx}
    
    \begin{document}
    \def\rowwidth{5}
    \def\rownumber{3}
    \def\threshold{12}
    \parindent 0pt
    \foreach \i in {0,...,\rownumber}{
      \foreach \j in {0,...,\rowwidth}{
        \pgfmathparse{ifthenelse((6*\i+\j>\threshold),"red","blue")}%
        \includegraphics[width=1cm]{\pgfmathresult}
      }
      \newline
    }
    \end{document}
    

    第一行只定义了绘图参数(\rowwidth 和 \rownumber)和颜色改变时的值(\threshold)。
    \foreach 允许循环,\i(或 \j)将采用连续值 0、1 等。
    \pgfmathparse 是 tikz 处理数学表达式的方式。我使用 ìfthenelse 数学函数计算其第一个参数 (6*\i+\j>12) 并将 \pgfmatresult 设置为其第二个或第三个参数。
    然后只需使用这个 \pgfmathresult 作为 \includegraphics

    的参数

    但是,例如,如果您的绘图是使用 tikz 完成的,您可以使用它来指定颜色。例如,我借用了这个 tex.se 线程 https://tex.stackexchange.com/questions/84275/custom-human-shape-for-tikz 下图与您的需求相似。

    \documentclass{article}
    \usepackage{tikz}
    \usepackage{graphicx}
    \usetikzlibrary{positioning,arrows}
    
    \begin{document}
    \newcommand{\body}[1]{
    \begin{tikzpicture}[#1]
      \node[circle,fill,minimum size=5mm] (head) {};
      \node[rounded corners=2pt,minimum height=1.3cm,minimum width=0.4cm,fill,below = 1pt of head] (body) {};
      \draw[line width=1mm,round cap-round cap] ([shift={(2pt,-1pt)}]body.north east) --++(-90:6mm);
      \draw[line width=1mm,round cap-round cap] ([shift={(-2pt,-1pt)}]body.north west)--++(-90:6mm);
      \draw[thick,white,-round cap] (body.south) --++(90:5.5mm);
    \end{tikzpicture}
    }
    
    \def\rowwidth{5}
    \def\rownumber{3}
    \def\threshold{12}
    \parindent 0pt
    \foreach \i in {0,...,\rownumber}{
      \foreach \j in {0,...,\rowwidth}{
        \pgfmathparse{ifthenelse((6*\i+\j>\threshold),"red","blue")}%
        \edef\mycolor{\pgfmathresult}
        \body{color=\mycolor}
      }
      \newline
    }
    \end{document}
    

    \edef允许保存 \pgfmathresult 并避免它被破坏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-13
      • 2017-12-07
      • 1970-01-01
      • 2015-04-01
      • 2020-08-17
      • 2012-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多