LyXLeft alignment and indentation

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
johnny7
Posts: 21
Joined: Fri Oct 24, 2014 12:25 pm

Left alignment and indentation

Post by johnny7 »

Hi,

My document requires a specific format which includes left alignment (instead of full justification) and indentation at the beginning of each paragraph (default).
However, it doesn't seem possible to combine these two commands. When I select the main text and choose left alignment via the paragraph settings, the indentation disappears although it is still selected in the text format settings. Instead, there is a small space between paragraphs in the created PDF. The formatting in Lyx looks fine.

Is there a way I can get both requirements working at the same time?
Thanks very much for your help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Left alignment and indentation

Post by Johannes_B »

You can copy the codeblock in the middle to your document preamble. It simply removes the part that sets the indent to zero.

Code: Select all

\documentclass{article}
\usepackage{blindtext}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\raggedright}{\parindent\z@}{}{}{}
\makeatother

\begin{document}
\raggedright
\blindtext

\blindtext
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Left alignment and indentation

Post by Stefan Kottwitz »

Hi Jonny,

a similar solution was posted by Thorsten here: Ragged Right Justification cancels Indentation.

Code: Select all

\newlength{\saveparindent}
\setlength{\saveparindent}{\parindent}
\raggedright
\setlength{\parindent}{\saveparindent}
You could insert this in the document preamble with LyX, or Johannes' very good suggestion

Code: Select all

\usepackage{etoolbox}
\makeatletter
\patchcmd{\raggedright}{\parindent\z@}{}{}{}
\makeatother
Stefan
LaTeX.org admin
johnny7
Posts: 21
Joined: Fri Oct 24, 2014 12:25 pm

Re: Left alignment and indentation

Post by johnny7 »

Thanks for your answers, but none of the proposed codes work me. I simply added them to the preamble as you said. The document does not directly start with left alignment if that changes anything. Is there another place I could insert the codeblocks?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Left alignment and indentation

Post by Stefan Kottwitz »

Hi Johnny,

could you please export your LyX document to LaTeX and post it as attachment? Of course you can remove confidential content, the most important to now is the preamble.

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Left alignment and indentation

Post by Johannes_B »

The document does not directly start with left alignment
Never does directly after a sectioning command, or in other words, this is by design. Please load package indentfirst to get the first paragraph after sectioning commands as well.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply