为什么我的乳胶枚举给我一个很大的差距?

发布于 2025-02-07 06:43:35 字数 1654 浏览 1 评论 0原文

我正在乳胶进行考试,但是由于某种原因,图像和下一个文本之间的空白空间很大。

\documentclass{article}%
\usepackage{tikz}%
\usepackage{enumitem}%
%
%
%
\begin{document}%

\begin{enumerate}
    \item{What is the bitstring of this $4\times 4$ pixel image?\newline
        \phantom{abcdefg}\begin{tikzpicture}[scale=.7]
            \path[fill=gray] (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0);
            \path[fill=gray] (0,2) -- (1,2) -- (1,3) -- (0,3) -- (0,2);
            \path[fill=gray] (3,2) -- (4,2) -- (4,3) -- (3,3) -- (3,2);
            \path[fill=gray] (2,2) -- (3,2) -- (3,3) -- (2,3) -- (2,2);
            \path[fill=gray] (1,2) -- (2,2) -- (2,3) -- (1,3) -- (1,2);
            \path[fill=gray] (2,1) -- (3,1) -- (3,2) -- (2,2) -- (2,1);
            \path[fill=gray] (2,3) -- (3,3) -- (3,4) -- (2,4) -- (2,3);
            \path[fill=gray] (3,3) -- (4,3) -- (4,4) -- (3,4) -- (3,3);
            \path[fill=gray] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
            \foreach \i in {0,...,4}{
                \draw [thin,black] (\i,0) -- (\i,4)  node [above] at (\i,-10){};
                \draw [thin,black] (0,\i) -- (4,\i)  node [above] at (\i,-10){};}
        \end{tikzpicture}\begin{enumerate}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
        \end{enumerate}}
\end{enumerate}

\end{document}

I'm making an exam in LaTex, but for some reason there's a large empty space between the image and the next text in my enumerate environment.

\documentclass{article}%
\usepackage{tikz}%
\usepackage{enumitem}%
%
%
%
\begin{document}%

\begin{enumerate}
    \item{What is the bitstring of this $4\times 4$ pixel image?\newline
        \phantom{abcdefg}\begin{tikzpicture}[scale=.7]
            \path[fill=gray] (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0);
            \path[fill=gray] (0,2) -- (1,2) -- (1,3) -- (0,3) -- (0,2);
            \path[fill=gray] (3,2) -- (4,2) -- (4,3) -- (3,3) -- (3,2);
            \path[fill=gray] (2,2) -- (3,2) -- (3,3) -- (2,3) -- (2,2);
            \path[fill=gray] (1,2) -- (2,2) -- (2,3) -- (1,3) -- (1,2);
            \path[fill=gray] (2,1) -- (3,1) -- (3,2) -- (2,2) -- (2,1);
            \path[fill=gray] (2,3) -- (3,3) -- (3,4) -- (2,4) -- (2,3);
            \path[fill=gray] (3,3) -- (4,3) -- (4,4) -- (3,4) -- (3,3);
            \path[fill=gray] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
            \foreach \i in {0,...,4}{
                \draw [thin,black] (\i,0) -- (\i,4)  node [above] at (\i,-10){};
                \draw [thin,black] (0,\i) -- (4,\i)  node [above] at (\i,-10){};}
        \end{tikzpicture}\begin{enumerate}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
            \item{$0011$ $1111$ $0010$ $1010$}
        \end{enumerate}}
\end{enumerate}

\end{document}

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

能怎样 2025-02-14 06:43:35

空间是如此之大,因为您的foreach循环中的空节点离图片很远。由于这些节点无论如何都是空的,因此您可以将它们删除并获取所需的边界框:

\documentclass{article}%
\usepackage{tikz}%
\usepackage{enumitem}%
%
%
%
\begin{document}%

\begin{enumerate}
    \item What is the bitstring of this $4\times 4$ pixel image?
    
        \begin{tikzpicture}%[scale=.7]
            \path[fill=gray] (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0);
            \path[fill=gray] (0,2) -- (1,2) -- (1,3) -- (0,3) -- (0,2);
            \path[fill=gray] (3,2) -- (4,2) -- (4,3) -- (3,3) -- (3,2);
            \path[fill=gray] (2,2) -- (3,2) -- (3,3) -- (2,3) -- (2,2);
            \path[fill=gray] (1,2) -- (2,2) -- (2,3) -- (1,3) -- (1,2);
            \path[fill=gray] (2,1) -- (3,1) -- (3,2) -- (2,2) -- (2,1);
            \path[fill=gray] (2,3) -- (3,3) -- (3,4) -- (2,4) -- (2,3);
            \path[fill=gray] (3,3) -- (4,3) -- (4,4) -- (3,4) -- (3,3);
            \path[fill=gray] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
            \foreach \i in {0,...,4}{
                \draw [thin,black] (\i,0) -- (\i,4);
                \draw [thin,black] (0,\i) -- (4,\i);
            }
        \end{tikzpicture}
        \begin{enumerate}
            \item $0011$ $1111$ $0010$ $1010$ 
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
        \end{enumerate}
\end{enumerate}

\end{document}

“在此处输入图像说明”

The space is so big, because your empty nodes in the foreach loop are so far away from your picture. As these nodes are anyway empty, you can remove them and get the desired bounding box:

\documentclass{article}%
\usepackage{tikz}%
\usepackage{enumitem}%
%
%
%
\begin{document}%

\begin{enumerate}
    \item What is the bitstring of this $4\times 4$ pixel image?
    
        \begin{tikzpicture}%[scale=.7]
            \path[fill=gray] (0,0) -- (1,0) -- (1,1) -- (0,1) -- (0,0);
            \path[fill=gray] (0,2) -- (1,2) -- (1,3) -- (0,3) -- (0,2);
            \path[fill=gray] (3,2) -- (4,2) -- (4,3) -- (3,3) -- (3,2);
            \path[fill=gray] (2,2) -- (3,2) -- (3,3) -- (2,3) -- (2,2);
            \path[fill=gray] (1,2) -- (2,2) -- (2,3) -- (1,3) -- (1,2);
            \path[fill=gray] (2,1) -- (3,1) -- (3,2) -- (2,2) -- (2,1);
            \path[fill=gray] (2,3) -- (3,3) -- (3,4) -- (2,4) -- (2,3);
            \path[fill=gray] (3,3) -- (4,3) -- (4,4) -- (3,4) -- (3,3);
            \path[fill=gray] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
            \foreach \i in {0,...,4}{
                \draw [thin,black] (\i,0) -- (\i,4);
                \draw [thin,black] (0,\i) -- (4,\i);
            }
        \end{tikzpicture}
        \begin{enumerate}
            \item $0011$ $1111$ $0010$ $1010$ 
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
            \item $0011$ $1111$ $0010$ $1010$
        \end{enumerate}
\end{enumerate}

\end{document}

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文