0

the table in my essay is followed by a pagebreak (as shown in the example), however, the {Heading} (text) is not properly left aligned. How can I solve this problem?

Thanks,


\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}
}

Karl L.
  • 325
  • it is not really a heading, you are right just a paragraph; the problem is that it is a bit too far right and does not alight where it should be (left to the side) – Karl L. Feb 24 '20 at 23:13
  • 1
    You need to provide an example of the problem, but as I say it will be indented (by around 15pt normally) as it is a paragraph start. – David Carlisle Feb 24 '20 at 23:13
  • I edited the information and but down the structure of the table – Karl L. Feb 24 '20 at 23:22
  • 1
    test is the start of a paragraph so (depending on code you have not shown) will be indented by paragraph indent. you could use \noindent to suppress that but noindent should never be used, the paragraph indention (or lack of it) should be set up as a global style in the document preamble. – David Carlisle Feb 24 '20 at 23:39

2 Answers2

1

Global setting for zero indent added in preamble

\setlength{\parindent}{0pt}

the output::

enter image description here MWE

\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}

The indentation can be changed midway in the document by adding

\setlength{\parindent}{1in}

and the output with above 1 inch setting::

enter image description here

PS

Do read the following while using the \parindent command --- https://tex.stackexchange.com/a/55016/197451

EDIT

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

The first parameter to fontsize is the font size to switch to and the second is the line spacing to use

js bibra
  • 21,280
0

If the start of a single paragraph should not be indented use \noindent in front of it:

\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}
esdd
  • 85,675