表格字段中的实心圆圈

表格字段中的实心圆圈

目前我正在使用 beamer 并且在一个框架中有一个表格:一切工作正常,除了我放置这个颜色填充的圆圈的地方表格分开了,但我希望圆圈只在表格字段内,而不是表格的左右两侧,如果你明白我的意思。

\documentclass[leqno,8pt,fleqn,table]{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}

\tikzset{
table/.style={
    matrix of nodes,
    row sep=-\pgflinewidth,
    column sep=-\pgflinewidth,
    nodes={
        rectangle,
        draw=black,
        align=center,
               },
                    %baseline={([yshift=-0.5ex]current bounding box.center)},
    minimum height=1.5em,
    text depth=0.5em,
    text height=1em,
            text centered,
    nodes in empty cells,
    %%
                            row 1/.style={
        nodes={
            fill=black,
            text=white,
            %font=\bfseries
        }
    },
            rows/.style={nodes={fill=gray!10}},
            columns/.style={nodes={text width = 10em}},
            %myrowstyle/.style={
                %row #1/.style={nodes={fill=gray!10}}
    %},
   }
}

\begin{document}
\begin{frame}
\begin{center}
\begin{tiny}
    \begin{tikzpicture}
    \matrix[table, rows={2,...,3}{fill=grey!10}, columns={1,...,5}{text width = 10em}, ampersand replacement=\&] (first)
    { 
        card \# \& date \& 1 \& 2 \& 3 \\
        ghul \& 01.01.2016 \& \fill[green] (1,0) circle (0.05); \& \fill[red] (1,0) circle (0.05); \& \fill[red] (1,0) circle (0.05); \\
};
\end{tikzpicture}
\end{tiny}
%\vspace{4mm}
\end{center}
\end{frame}
\end{document}

答案1

如果我理解你想要的是绿色和红色的圆圈,在里面 (first-2-3)(first-2-4)(first-2-5)。其中表示矩阵内的2行号和3,4,5列号,这里有一个解决方案first

\documentclass[leqno,8pt,fleqn,table]{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,shadings}

\def\r{0.1}

\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            rectangle,
            draw=black,
            align=center,
                   },
                        %baseline={([yshift=-0.5ex]current bounding box.center)},
        minimum height=1.5em,
        text depth=0.5em,
        text height=1em,
                text centered,
        nodes in empty cells,
%%
                                row 1/.style={
            nodes={
                fill=black,
                text=white,
                %font=\bfseries
            }
        },
                rows/.style={nodes={fill=gray!10}},
                columns/.style={nodes={text width = 10em}},
                %myrowstyle/.style={
                    %row #1/.style={nodes={fill=gray!10}}
        %},
    }
}

\begin{document}
\begin{frame}
\begin{center}
\begin{tiny}
    \begin{tikzpicture}
    \matrix[table, rows={2,...,3}{fill=grey!10}, columns={1,...,5}{text width = 10em}, ampersand replacement=\&] (first)
    { 
        card \# \& date \& 1 \& 2 \& 3 \\
        ghul \& 01.01.2016 \&  \&  \&  \\
};

\fill[left color=green,right color=red] (first-2-3) circle (\r);
\fill[red] (first-2-4) circle (\r);
\fill[red] (first-2-5) circle (\r);

\end{tikzpicture}
\end{tiny}
%\vspace{4mm}
\end{center}
\end{frame}
\end{document}

输出

在此处输入图片描述

相关内容