With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space
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}
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
\newcommand{\paragraphStyle}[1]{\setlength{\parindent}{0pt}\setlength{\parskip}{0.16in}\renewcommand{\baselinestretch}{2.0}\color{black!100}\fontsize{20pt}{24pt}\selectfont{\textbf{#1}}\color{black!100}\normalsize\setlength{\parindent}{0em}\setlength{\parskip}{0.08in}\selectfont\renewcommand{\baselinestretch}{1.0}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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}