# With indentation set to 0em, when using a line break, there is still an indentation of a size of a space

## Problem Description

I am quite a newbie at *TeX, but I defined some \newcommands as some kind of paragraph styles (maybe not the proper way to do so, maybe someone could tell me how to accomplish this better).

I want to have default paragraph style with no indentation, space after paragraph should be 0.08", space before paragraph should be 0". However, any of the paragraph style could change any of these settings and some something more (like character styles, e.g. bold, italics, underline, etc).

Now, sometimes I want to insert a paragraph in particular paragraph style without space after that paragraph. For that I use line break (\\), which usually does the job. However, with the \paragraphStyle below, this is broken.

It seems like if in the first paragraph, there is an indentation of a size of a space, which I cannot elimininate, no matter what I do.

## What I have Tried

I tried to use \noindent and \setlength{\parindent}{0em} in many different combinations.

## Minimal Working Example

%%%%%  Preamble  %%%%%
\documentclass[10pt]{book}
\usepackage[a4paper]{geometry}
\geometry{
a4paper,
left=1in,
right=1in,
top=1in,
bottom=1in,
portrait
}

\usepackage{xcolor}

% Font family
\usepackage[math-style=ISO, bold-style=ISO, partial=upright, nabla=upright]{unicode-math}
\setmainfont{Libertinus Serif}

% Paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line \expandafter\selectlanguage\expandafter{\cvlang}

% Custom commands

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\pagestyle{empty}

This is wrong:

\paragraphStyle{
First line\\
Second line
}

This is correct:

\paragraphStyle{First line}\\
\paragraphStyle{Second line}

Also this is correct in indentation, but not in space after paragraph:

First Line\\
Second Line
\end{document}


## Output

• this is really a very strange definition you are setting parindent and parskip hidden inside \pargraphStyle but they are not in any local group so they apply to the rest of the document not just the text in the argument. I would seriously consider not using this markup and using a more normal latex constrict. Apr 24, 2019 at 19:30
• @DavidCarlisle, what do you advise to do? How should I define styles correctly? What markup should I use? Apr 24, 2019 at 20:58
• You don't give any indication of the intended use, what is this large text for, is it some kind of heading? It is hard to suggest a reasonable markup with the information given. Apr 24, 2019 at 21:01
• This particular style is a text body paragraph with large(r) font size for easier readability. In the end, I’d like to create more styles (just imagine those of any word processor like LibreOffice Writer or MS Office Word). Anyway, here’s an actual pdf I am currenly working on—I’d like to create a style for all different styles I need to create that file. Apr 24, 2019 at 21:15

As Marcel pointed out, there is a stray space in your input. You can remove that space, as Marcel suggests, or you can add \ignorespaces, within your macro definition, to your argument of \textbf, prior to #1. Also, there is no need for the \textbf{} to be in its own braces, so I removed it.

Note: an alternative for that part of the definition that now reads \textbf{\ignorespaces#1} could also be {\bfseries#1}. Here, the braces are now necessary to limit the scope, but the \ignorespaces is no longer required because \bfseries leaves you in vertical mode, so the leading space in #1 is ignored, whereas \textbf{} puts you in horizontal mode, where the leading space counts.

Also, I reorganized your definition of \paragraphStyle to make it easier for humans to read. Note the presence of % end-of-line delimiters, to avoid the very same problem again.

\documentclass[10pt]{book}
\usepackage[a4paper]{geometry}
\geometry{
a4paper,
left=1in,
right=1in,
top=1in,
bottom=1in,
portrait
}

\usepackage{xcolor}

% Font family
%\usepackage[math-style=ISO, bold-style=ISO, partial=upright, nabla=upright]{unicode-math}
%\setmainfont{Libertinus Serif}

% Paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line \expandafter\selectlanguage\expandafter{\cvlang}

% Custom commands
\newcommand{\paragraphStyle}[1]{%
\setlength{\parindent}{0pt}%
\setlength{\parskip}{0.16in}%
\renewcommand{\baselinestretch}{2.0}%
\color{black!100}%
\fontsize{20pt}{24pt}%
\selectfont%
\textbf{\ignorespaces#1}%
\color{black!100}%
\normalsize%
\setlength{\parindent}{0em}%
\setlength{\parskip}{0.08in}%
\selectfont%
\renewcommand{\baselinestretch}{1.0}%
}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\pagestyle{empty}

This is no longer wrong:

\paragraphStyle{
First line\\
Second line
}

This is correct:

\paragraphStyle{First line}\\
\paragraphStyle{Second line}

Also this is correct in indentation, but not in space after paragraph:

First Line\\
Second Line
\end{document}


• \ignorespaces is no longer required, because the space is absorbed in the aftermath of the macro \bfseries no:-) Apr 24, 2019 at 19:30
• @DavidCarlisle Why do you say that? \bfseries<space><space><space><etc> #1 also produces no introduced spaces. What's the right terminology to describe this process? Apr 24, 2019 at 19:42
• \ignorespaces was there to ignore spaces that are passed in at the start of #1 they would not be dropped in the way that a literal space after \bfseries is dropped. Apr 24, 2019 at 19:44
• @DavidCarlisle OK... But they are nonetheless dropped. Why? Apr 24, 2019 at 19:45
• @tukusejssirs Think of horizontal mode as building the contents of a paragraph (e.g., indents, justifications, word wrapping, etc), and vertical mode as laying out a collection of paragraphs on the page (e.g., vertical gaps, locating floats, etc.) Apr 25, 2019 at 9:47

The "indentation of a size of a space" actually isn't an indentation, it is a space at the start of the line:

Look at

    This is wrong:

\paragraphStyle{
First line\\
Second line
}


The newline after \paragraphStyle{ is converted to a space which results in the observed "indentation". You can avoid this by adding a % to comment the newline, suppressing the space:

    This is wrong:

\paragraphStyle{%
First line\\
Second line
}


The full document becomes

%%%%%  Preamble  %%%%%
\documentclass[10pt]{book}
\usepackage[a4paper]{geometry}
\geometry{
a4paper,
left=1in,
right=1in,
top=1in,
bottom=1in,
portrait
}

\usepackage{xcolor}

% Font family
\usepackage[math-style=ISO, bold-style=ISO, partial=upright, nabla=upright]{unicode-math}
\setmainfont{Libertinus Serif}

% Paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line \expandafter\selectlanguage\expandafter{\cvlang}

% Custom commands

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\pagestyle{empty}

This is wrong:

\paragraphStyle{%
First line\\
Second line
}

This is correct:

\paragraphStyle{First line}\\
\paragraphStyle{Second line}

Also this is correct in indentation, but not in space after paragraph:

First Line\\
Second Line
\end{document}


You should use grouping to isolate the changes in font and line spacing, so you don't have to revert them afterwards. However, since these changes have to be done, you need to end the previous paragraph, if not already done and also to end a paragraph at the end of the special setup, so as not to influence the following paragraphs.

%%%%%  Preamble  %%%%%
\documentclass[10pt]{book}
\usepackage[a4paper]{geometry}
\geometry{
a4paper,
left=1in,
right=1in,
top=1in,
bottom=1in,
portrait,
}

\usepackage{xcolor}

% Font family
\usepackage[math-style=ISO, bold-style=ISO, partial=upright, nabla=upright]{unicode-math}
\setmainfont{Libertinus Serif}

% Paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line

% Custom commands
\newcommand{\paragraphStyle}[1]{%
\par
\begingroup
\setlength{\parindent}{0pt}%
\setlength{\parskip}{0.16in}%
\renewcommand{\baselinestretch}{2.0}%
\fontsize{20pt}{24pt}\selectfont
\noindent\color{black!100}%
\bfseries\ignorespaces #1\par
\endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\pagestyle{empty}

This is right:

\paragraphStyle{
First line\\
Second line
}

Also this is correct in indentation, but not in space after paragraph:

First Line\\
Second Line

\end{document}


• Thank you. All three of you has a bit of information I need to incorporate into the document, that is (1) in the \newcommand, I need to add a group; (2) beware of ‘stray spaces’ (newlines converted into spaces). Apr 25, 2019 at 7:15
• @egrep, could you check my updated question, please? :) Apr 25, 2019 at 9:01
• @tukusejssirs Please, note that my nickname is not egrep. Just remove the \\, that does nothing after \par besides raising an error: \paragraphStyle{First line}\\ should be \paragraphStyle{First line}. Then roll back your question removing the last edit. Apr 25, 2019 at 9:08
• I apologise for misspelling your nickname. :) … Yes, I’ve just found the very same behaviour. Is there another way to make it work with \ without another ‘instance’ of \paragraphStyle? Apr 25, 2019 at 9:25
• And it does not align the right side of the first line of the second paragraph in this code: \paragraphStyle{Bratia a sestry, v tuto presvatu noc nas Pan Jezis Kristus vstal z mrtvych. Preto Cirkev po celom svet zvolava svojich synov a dcery a zhromazduje ich, aby bedlili a modlili sa. Aj my sme prijali toto pozvanie.\n\nPripomenieme si Panovo zmrtvychvstanie, budeme pocuvat Bozie slovo a oslavime velkonocne tajomstvo v nadeji, ze budeme mat podiel na Kristovom vitazstve nad smrtou a na jeho zivote v Bohu.}. Apr 25, 2019 at 9:41