遇到格式问题,我似乎无法解决

遇到格式问题,我似乎无法解决

在此处输入图片描述

从图片中您应该可以看到,我的枚举环境似乎运行良好,直到我排版表格,然后内容移到左边距。我希望 (a) 和 (b) 对齐,并且表格也位于右侧。

有小费吗?

这是我的代码...

\documentclass{article}
\renewcommand{\thesection}{\Roman{section}} 
\renewcommand{\thesubsection}{\thesection.\Roman{subsection}}

\usepackage{setspace}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{amsfonts}


\RequirePackage[left=1.5in,right=1.5in,top=1.5in,bottom=1.5in]{geometry}

\newcommand\state[1]{\ensuremath{q_{#1}}}
\newcommand\blank{\ensuremath{\sqcup}}
\newcommand\lang{\ensuremath{\mathcal{L}}}



\begin{document}



    \begin{enumerate}
        \item \textbf{Programming Turing Machines}
        \begin{enumerate}
            \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma. \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ is\ divisible\ by\ 4 \}$, ignoring trailing 0s; treat blank string as a 0.
            \begin{align*}
                M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)\\
                Q=\{q_{0},q_{1},q_{2},q_{accept},q_{reject}\}\\
                \Gamma=\{0,1,\blank\}\\
                \Sigma=\Gamma\setminus\{\blank\}
            \end{align*}

            \captionof{table}{$\delta: Q\times \Gamma \to Q\times \Gamma\times \{L,R\}$}
            \begin{tabular}{c|c|c|c|c}              
                Current State&Current Character&New State&New Character&Move\\
                \hline
                \state{0}&1&\state{0}&1&R\\
                \state{0}&0&\state{0}&0&R\\
                \state{0}&\blank&\state{1}&\blank&L\\
                \state{1}&1&\state{reject}&-&-\\
                \state{1}&0&\state{2}&0&L\\
                \state{2}&1&\state{reject}&-&-\\
                \state{2}&0&\state{accept}&-&-\\
                \hline
            \end{tabular}

            \bigskip

            \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ does\ not\ have\ repeating\ 1s \}$. ( e.g., x = 110 is rejected and x = 1001 is accepted. )

            \begin{align*}
                M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)\\
                Q=\{q_{0},q_{1},q_{2},q_{accept},q_{reject}\}\\
                \Gamma=\{0,1,\blank\}\\
                \Sigma=\Gamma\setminus\{\blank\}
            \end{align*}

            \captionof{table}{$\delta: Q\times \Gamma \to Q\times \Gamma\times \{L,R\}$}        
            \begin{tabular}{c|c|c|c|c}              
                Current State&Current Character&New State&New Character&Move\\
                \hline
                \state{0}&1&\state{0}&1&R\\
                \state{0}&0&\state{0}&0&R\\
                \state{0}&\blank&\state{1}&\blank&L\\
                \state{1}&1&\state{2}&1&L\\
                \state{1}&0&\state{1}&0&L\\
                \state{1}&\blank&\state{accept}&-&-\\
                \state{2}&1&\state{reject}&-&-\\
                \state{2}&0&\state{1}&0&L\\
                \hline
            \end{tabular}

            \bigskip

            \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ does\ not\ have\ repeating\ 1s \}$. ( e.g., x = 110 is rejected and x = 1001 is accepted. )
        \end{enumerate}
    \end{enumerate}

\end{document}

答案1

问题似乎是\captionof重置了环境的左边距和右边距enumerate

像这样嵌入\captionof内部\parbox

\parbox{\linewidth}{\captionof{table}{$\delta: Q\times \Gamma \to Q\times \Gamma\times \{L,R\}$}}

使用应该可以得到d 列表\linewidth中的正确居中。这是因为LaTeX 使用该参数来确定当时一行的长度。注意不会给出正确的宽度。enumerate\linewidth\textwidth

此解决方案会产生一些您可能不想要的额外垂直空间。但您可以通过添加\vspace{<dim>}适当设置的负尺寸来轻松解决此问题。

这是我的 MWE 的完整副本:

\documentclass{article}
\renewcommand{\thesection}{\Roman{section}} 
\renewcommand{\thesubsection}{\thesection.\Roman{subsection}}

\usepackage{setspace}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{amsfonts}

\RequirePackage[left=1.5in,right=1.5in,top=1.5in,bottom=1.5in]{geometry}

\newcommand\state[1]{\ensuremath{q_{#1}}}
\newcommand\blank{\ensuremath{\sqcup}}
\newcommand\lang{\ensuremath{\mathcal{L}}}

\begin{document}

\begin{enumerate}
    \item \textbf{Programming Turing Machines}
    \begin{enumerate}
        \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma. \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ is\ divisible\ by\ 4 \}$, ignoring trailing 0s; treat blank string as a 0.
        \begin{align*}
            M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)\\
            Q=\{q_{0},q_{1},q_{2},q_{accept},q_{reject}\}\\
            \Gamma=\{0,1,\blank\}\\
            \Sigma=\Gamma\setminus\{\blank\}
        \end{align*}

        \parbox{\linewidth}{\captionof{table}{$\delta: Q\times \Gamma \to Q\times \Gamma\times \{L,R\}$}}\vspace{-1ex}
        \begin{tabular}{c|c|c|c|c}              
            Current State&Current Character&New State&New Character&Move\\
            \hline
            \state{0}&1&\state{0}&1&R\\
            \state{0}&0&\state{0}&0&R\\
            \state{0}&\blank&\state{1}&\blank&L\\
            \state{1}&1&\state{reject}&-&-\\
            \state{1}&0&\state{2}&0&L\\
            \state{2}&1&\state{reject}&-&-\\
            \state{2}&0&\state{accept}&-&-\\
            \hline
        \end{tabular}

        \bigskip

        \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ does\ not\ have\ repeating\ 1s \}$. ( e.g., x = 110 is rejected and x = 1001 is accepted. )

        \begin{align*}
            M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)\\
            Q=\{q_{0},q_{1},q_{2},q_{accept},q_{reject}\}\\
            \Gamma=\{0,1,\blank\}\\
            \Sigma=\Gamma\setminus\{\blank\}
        \end{align*}

        \parbox{\linewidth}{\captionof{table}{$\delta: Q\times \Gamma \to Q\times \Gamma\times \{L,R\}$}}\vspace{-1ex}
        \begin{tabular}{c|c|c|c|c}              
            Current State&Current Character&New State&New Character&Move\\
            \hline
            \state{0}&1&\state{0}&1&R\\
            \state{0}&0&\state{0}&0&R\\
            \state{0}&\blank&\state{1}&\blank&L\\
            \state{1}&1&\state{2}&1&L\\
            \state{1}&0&\state{1}&0&L\\
            \state{1}&\blank&\state{accept}&-&-\\
            \state{2}&1&\state{reject}&-&-\\
            \state{2}&0&\state{1}&0&L\\
            \hline
        \end{tabular}

        \bigskip

        \item  Give a full description of a Turing machine $M = (Q, \Sigma, \Gamma, \state{0}, \state{accept}, \state{reject}, \delta)$ accepting a language $\lang = \{x \in \{0,1\}^{*}\ |\ x\ does\ not\ have\ repeating\ 1s \}$. ( e.g., x = 110 is rejected and x = 1001 is accepted. )
    \end{enumerate}
\end{enumerate}

\end{document}

在此处输入图片描述

相关内容