表格/分页符后的文本没有左对齐?

表格/分页符后的文本没有左对齐?

我的文章中的表格后面有分页符(如示例所示),但是 {Heading}(文本)没有正确左对齐。我该如何解决这个问题?

谢谢,


\pagebreak 
\sffamily \large \textbf{test} % this is the problem, here the text is not as left aligned to the left side of the page as it should be; further information: before the \pagebreak is another table 
{\setlength{\tabcolsep}{4pt}
\sffamily
\small
\begin{longtable}{p{15cm}}
\caption{tets }\\[2ex]
\hline 
\textcolor{black}{test)} \\
\hline
\textcolor{black}{\textbf{test}} \\
\hline
\small test\\
\hline
\textcolor{black}{\textbf{test}} \\ 
\hline
\small test \\
\hline
\textcolor{black}{\textbf{C}} \\
\hline
\small test \\
\hline
\end{longtable}
}

答案1

在序言中添加了零缩进的全局设置

\setlength{\parindent}{0pt}

输出::

在此处输入图片描述 平均能量损失

\documentclass[11pt]{article} 
% \usepackage[demo]{graphicx} 
% \usepackage{booktabs}
\usepackage{longtable}
\usepackage{xcolor}
\setlength{\parindent}{0pt}%<______for zero indent in the whole document set to zero
% \setlength{\parindent}{1in}%<_________indent length variation can be set before 
                            %the paragraph or for the whole document
\begin{document} 
\pagebreak 
\sffamily \large \textbf{test} % this is the problem, here the text is not as left aligned to the left side of the page as it should be; further information: before the \pagebreak is another table 
{\setlength{\tabcolsep}{4pt}
\sffamily
\small
\begin{longtable}{p{15cm}}
\caption{tets }\\[2ex]
\hline 
\textcolor{black}{test)} \\
\hline
\textcolor{black}{\textbf{test}} \\
\hline
\small test\\
\hline
\textcolor{black}{\textbf{test}} \\ 
\hline
\small test \\
\hline
\textcolor{black}{\textbf{C}} \\
\hline
\small test \\
\hline
\end{longtable}
}
\end{document}

可以在文档中途通过添加来更改缩进

\setlength{\parindent}{1in}

输出设置高于 1 英寸::

在此处输入图片描述

附言

使用 \parindent 命令时请阅读以下内容 ---https://tex.stackexchange.com/a/55016/197451

编辑

\fontsize{10pt}{12pt}\selectfont
\begin{verbatim}  
    % how to set font size here to 10 px ?  
\end{verbatim}  

fontsize 的第一个参数是要切换到的字体大小,第二个参数是要使用的行距

答案2

如果单个段落的开头不应该缩进,请\noindent在其前面使用:

\documentclass[11pt]{article}
\usepackage{lipsum}% only for dummy text
\usepackage{longtable}
\usepackage{xcolor}

\begin{document} 
\lipsum[1]

\pagebreak

\noindent% <- avoids the \parindent
{\sffamily \large \textbf{test}\par}% <- changed to limit the font change
{\setlength{\tabcolsep}{4pt}
\sffamily
\small
\begin{longtable}[l]{p{\dimexpr\textwidth-2\tabcolsep\relax}}
\caption{tets }\\[2ex]
\hline 
\textcolor{black}{test)} \\
\hline
\textcolor{black}{\textbf{test}} \\
\hline
\small test\\
\hline
\textcolor{black}{\textbf{test}} \\ 
\hline
\small test \\
\hline
\textcolor{black}{\textbf{C}} \\
\hline
\small test \\
\hline
\end{longtable}
}

\lipsum[2]
\end{document}

相关内容