LyXNo automatic line break in paragraph title

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
sim0ne
Posts: 11
Joined: Wed Dec 23, 2015 12:29 pm

No automatic line break in paragraph title

Post by sim0ne »

Hi.

I've been using LyX for quite a while now, but now i faced a problem i never had before:
in paragraph titles, there is no line break, so the title goes over the margin of the mage. same think with the title in the table of contents.

can somebody help me? thanks in advance.

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

No automatic line break in paragraph title

Post by Johannes_B »

Welcome,

paragraph was a strangely chosen word for a sectional heading and it leads to confusion.
In case you are putting whole paragraphs of text into paragraphs, don't.

If not, and i think you don't, can you show us a very minimal lyx example? Even better would be the export to LaTeX.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
sim0ne
Posts: 11
Joined: Wed Dec 23, 2015 12:29 pm

No automatic line break in paragraph title

Post by sim0ne »

Hi.

well, i sort of HAVE to use some pretty long titles. i tried it with "normal language", and the line breaks seem to work fine. but if it's names of chemicals, for example, lyx just doesn't know where to put the break.

on some names, it gets it right, on others it doesn't.

Code: Select all

%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{float}
\usepackage{textcomp}
\usepackage{setspace}
\usepackage{subscript}
\onehalfspacing

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\hyphenation{penta-methyl-cyclo-penta-dienyl}

\usepackage{caption}
\usepackage{tocloft}
\usepackage{overcite}
\usepackage{longtable}
\makeatletter
\renewcommand\@biblabel[1]{#1 }
\def\@citess#1{\textsuperscript{[#1]}}
\makeatother
\captionsetup{margin=15pt,font={small,rm},labelfont={small,sl, bf},format=plain,indention=0em,labelsep=colon,justification=centering,position=bottom}
\setcounter{page}{-4}
\addtolength{\cftparskip}{1pt}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\tolerance=4000
\makeatletter
\@addtoreset{figure}{section}
\@addtoreset{figure}{subsection}
\@addtoreset{figure}{subsubsection}
\@addtoreset{figure}{paragraph}
\makeatother
%\renewcommand*{\figureformat}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}.\arabic{figure}}
\renewcommand\thefigure{\thesection%
  \ifnum\arabic{subsection} = 0 \relax\else  .\arabic{subsection}\fi%
  \ifnum\arabic{subsubsection} = 0 \relax\else  .\arabic{subsubsection}\fi%
  \ifnum\arabic{paragraph} = 0 \relax\else  .\arabic{paragraph}\fi%
  -\arabic{figure}%
}

\makeatother

\usepackage{babel}
\begin{document}
\tableofcontents{}


\section{(in,in-\{{[}RuII(trpy)(H\protect\textsubscript{2}O){]}\protect\textsubscript{2}(\textmu -bpp)\}\protect\textsuperscript{3+ }(2,2\textasciiacute :6\textasciiacute ,2\textasciiacute \textasciiacute -terpyridine,
bis(2-pyridyl)-3,5-pyrazolate))}


\subsection{(in,in-\{{[}RuII(trpy)(H\protect\textsubscript{2}O){]}\protect\textsubscript{2}(\textmu -bpp)\}\protect\textsuperscript{3+ }(2,2\textasciiacute :6\textasciiacute ,2\textasciiacute \textasciiacute -terpyridine,
bis(2-pyridyl)-3,5-pyrazolate))}


\subsubsection{(in,in-\{{[}RuII(trpy)(H\protect\textsubscript{2}O){]}\protect\textsubscript{2}(\textmu -bpp)\}\protect\textsuperscript{3+ }(2,2\textasciiacute :6\textasciiacute ,2\textasciiacute \textasciiacute -terpyridine,
bis(2-pyridyl)-3,5-pyrazolate))}


\paragraph{(in,in-\{{[}RuII(trpy)(H\protect\textsubscript{2}O){]}\protect\textsubscript{2}(\textmu -bpp)\}\protect\textsuperscript{3+ }(2,2\textasciiacute :6\textasciiacute ,2\textasciiacute \textasciiacute -terpyridine,
bis(2-pyridyl)-3,5-pyrazolate))}

$\;$

m
\end{document}
so, here's the resulting PDF:
Attachments
sim0neLyxToc.png
sim0neLyxToc.png (183.72 KiB) Viewed 15191 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: No automatic line break in paragraph title

Post by Johannes_B »

That was recently discussed in our german sister forum. http://golatex.de/viewtopic,p,78466.html#78466


When i have more time, i add some explanation here 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.
sim0ne
Posts: 11
Joined: Wed Dec 23, 2015 12:29 pm

Re: No automatic line break in paragraph title

Post by sim0ne »

thanks for the link.
i do speak german, and i see that it's quite the same problem as mine. still, i'm not THAT much into latex to understand what's going on. that's the reason why i'm using LyX :oops:

so if there is a WYSIWYG kind of solution to this problem, please let me know. if you can somehow explain it in german, i could translate it so you have less work to do putting it up here on the english forum as well.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

No automatic line break in paragraph title

Post by cgnieder »

Chemical names always are a problem and there is no one fits all solution. However, there are measures you can take to make things easier. As a LyX user they would require ERT, though…

For one thing I'd use the microtype package and chemmacros in combination with chemformula. This should help in many cases already:

Code: Select all

\documentclass[12pt,ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\geometry{
  verbose,
  tmargin=2.5cm,
  bmargin=2.5cm,
  lmargin=2.5cm,
  rmargin=2.5cm
}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{microtype}

\usepackage{babel}

\usepackage{chemmacros}
\chemsetup{
  formula = chemformula ,
  greek = upgreek
}

\newcommand*\chemprime{\ensuremath{^\prime}}
\NewChemIUPACShorthand'\chemprime

\begin{document}

\tableofcontents

\section{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}

\subsection{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}

\subsubsection{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}

\paragraph{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}
Hello

\end{document}
iupac1.png
iupac1.png (73.61 KiB) Viewed 15156 times
Adding \sloppy at appropriate places may cure the remaining problems:

Code: Select all

\documentclass[12pt,ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\geometry{
  verbose,
  tmargin=2.5cm,
  bmargin=2.5cm,
  lmargin=2.5cm,
  rmargin=2.5cm
}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{microtype}

\usepackage{babel}

\usepackage{chemmacros}
\chemsetup{
  formula = chemformula ,
  greek = upgreek
}

\newcommand*\chemprime{\ensuremath{^\prime}}
\NewChemIUPACShorthand'\chemprime

\begin{document}

\tableofcontents

\section{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}

{\sloppy
\subsection{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}
}

{\sloppy
\subsubsection{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}
}

\paragraph{\ch{(in,in) "-" \{[RuII(trpy)(H2O)]2( "\m-bpp" )\}^3+}
  (\iupac{2,2':6',2''-ter|pyridine, bis(2-pyridyl)-3,5-pyrazolate)})}
Hello

\end{document}
iupac2.png
iupac2.png (73.9 KiB) Viewed 15156 times
Regards
site moderator & package author
sim0ne
Posts: 11
Joined: Wed Dec 23, 2015 12:29 pm

Re: No automatic line break in paragraph title

Post by sim0ne »

wow, that's very nice. thanks a lot.

but still, the headlines are too long for the page number to show up. they should be even shorter. is that possible?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

No automatic line break in paragraph title

Post by cgnieder »

sim0ne wrote:but still, the headlines are too long for the page number to show up. they should be even shorter. is that possible?
What do you mean by headlines? The header?
site moderator & package author
Post Reply