1

I have a list of items as follows:

\begin{itemize}
\item define \textit{N} to be the largest non-negative integer such that $k\times 4^{H-1}<max(f(X(t);4,3), f(X(t);5,7))$. If $f(X(t);0,-1)>k\times 4^{H-1}$ and blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla.
\end{itemize}

enter image description here

The problem is that the first line is too long (see picture=. How can I make the expression inside the math mode naturally go into the next line as if it was text?

My preamble

%\UseRawInputEncoding
\documentclass[12pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{titlesec}
%\titleformat{\section}
% {\normalfont\fontsize{12}{15}\bfseries}{\thesection}{1em}{}
% \usepackage{titlesec}
%\titleformat{\subsection}
% {\normalfont\fontsize{12}{15}\bfseries}{\thesubsection}{1em}{}
\usepackage{amsmath,amsfonts,amssymb}
\newcommand*{\defeq}{\stackrel{\text{def}}{=}}
\usepackage{color,xcolor}
\usepackage{subfig} 
\usepackage[pdftex]{graphicx}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{lscape,url}
\usepackage[round]{natbib}
\usepackage{lipsum}
\usepackage[hidelinks]{hyperref}
\usepackage[labelfont={bf},labelsep=colon,justification=justified]{caption}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{ \arraybackslash}p{#1}}
\usepackage{eurosym}
\usepackage{titlesec}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{placeins}
\usepackage{bookmark}
\usepackage[english]{babel}
\usepackage[autostyle, english = american]{csquotes}
\usepackage{indentfirst}
%\usepackage[multiple]{footmisc}
%\usepackage{appendix}
\usepackage[top=1.5in, bottom=1.5in, left=0.9in, right=0.9in]{geometry}
\topmargin -1.5cm
\oddsidemargin -0.04cm
\evensidemargin -0.04cm
\textwidth 16.59cm
\textheight 21.94cm
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{threeparttable}
\setcounter{MaxMatrixCols}{10}
\newtheorem{theorem}{Theorem}
\newtheorem{acknowledgement}[theorem]{Acknowledgement}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{axiom}[theorem]{Axiom}
\newtheorem{case}[theorem]{Case}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conclusion}[theorem]{Conclusion}
\newtheorem{condition}[theorem]{Condition}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{criterion}[theorem]{Criterion}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{solution}[theorem]{Solution}
\newtheorem{summary}[theorem]{Summary}
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\renewcommand{\baselinestretch}{2}
\newcommand\cites[1]{\citeauthor{#1}'s\ (\citeyear{#1})}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{comment}
\usepackage{multirow}
\usepackage{textcomp}
\interfootnotelinepenalty=10000
\usepackage[bottom]{footmisc}
\usepackage[labelsep=period]{caption}
\usepackage{lscape} 
\usepackage{blindtext}
\usepackage{dcolumn}
\usepackage{capt-of}
\newcolumntype{d}[1]{D{.}{.}{#1}}
%\usepackage{siunitx}
%\usepackage{mathptmx,siunitx}
%\sisetup{input-symbols = {()},  % do not treat "(" and ")" in any special way
  %       group-digits  = false} % no grouping of digits
\usepackage{tablefootnote}
\setlength{\footskip}{65pt}
\onehalfspacing
%\usepackage{etoolbox}
%\usepackage{xr}
%\externaldocument[SND-]{NetworkDescription}
\usepackage{titlesec}
\makeatletter
\newcommand{\setappendix}{Appendix~\thechapter:~}
\newcommand{\setchapter}{\thechapter~}
\titleformat{\chapter}{\bfseries\LARGE}{%
  \ifnum\pdfstrcmp{\@currenvir}{appendices}=0
    \setappendix
  \else
    \setchapter
  \fi}{0em}{}
\makeatother
\usepackage[titletoc]{appendix}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@maketitle}{\LARGE}{\fontsize{16}{17}\selectfont}{}{}
\makeatother
\begin{document}
  • 1
    Latex does not automatically allow line breaks after comma in math. You can use say ,\allowbreak and similar in certain places to give some breaking possibilities for the algorithm – daleif Jan 03 '22 at 21:30
  • 1
    using your code fragment in standard article document, i.e.: \documentclass{article} \begin{document} \begin{itemize} \item define $N$ to be the largest non-negative integer such that $k\times 4^{H-1}<\max(f(X(t);4,3), f(X(t);5,7))$. If $f(X(t);0,-1)>k\times 4^{H-1}$ and bla bla bla blabla bla blablabla blablabla blablabla blablabla blablabla blablabla blblabla blablabla blablabla bla blabla blablabla blablabla bla bla bla blablabla. \end{itemize} \end{document} doesn't reproduce your problem. Please extent it complete small document (MWE: Minimal Working Example). – Zarko Jan 03 '22 at 21:54
  • @Zarko Thanks. i added the info. Should work now. – Daniel Pinto Jan 03 '22 at 21:57
  • @ \allowbreak works. is there another way of doing this (more general and not involving me deciding manually on the break location)? – Daniel Pinto Jan 03 '22 at 22:04
  • Please make your document example minimal. Remove from preamble all what is not related to your problem. BTW, your preamble is a mess. Remove all duplicates and and reconsider whether you need all these packages ... – Zarko Jan 03 '22 at 22:13
  • 2
    I don't know of any "automatic" solution that you are looking for. Allowing a break after every comma is unsatisfactory; the decision (at present) is really best made by a human. One approach is to make this equation an unnumbered display; that is what might be chosen by a trained copyeditor. Otherwise, \allowbreak is really the best available approach. – barbara beeton Jan 03 '22 at 23:32
  • What about using displayed math? "...define $N$ to be the non-negative integer such that [ k\times 4^{H-1}<max(f(X(t);4,3), f(X(t);5,7)). ] If ..." – Sandy G Jan 05 '22 at 01:00

2 Answers2

1

I would suggest rephrasing the sentence and offer the following example for your reference.

\begin{itemize}
\item define $k\times 4^{N-1}<\max(f(X(t);4,3), f(X(t);5,7))$ with \textit{N} being the largest non-negative integer. If $f(X(t);0,-1)>k\times 4^{H-1}$ and \ldots
\end{itemize}
Bernard
  • 271,350
W. Zhu
  • 71
  • 7
  • Thanks. This is helpful, but not the general solution I am looking for. – Daniel Pinto Jan 03 '22 at 22:05
  • You are welcome. I've tried to look for an improved solution for you and find \sloppy could also work in your case. ( I am not sure whether it is also recommended.) I hope this page might be of some use. – W. Zhu Jan 03 '22 at 23:16
0

I've simplified your lengthy preamble to what I believe is the bare minimum needed to reproduce the formating issue you're looking to fix.

Basically, TeX does not like to allow line breaks in inline math, including right after commas. To enable a line break at a specific point, insert an \allowbreak directive as needed.

enter image description here

\documentclass[12pt]{article}
\textwidth 16.59cm
\oddsidemargin -0.04cm
\evensidemargin -0.04cm
\usepackage[T1]{fontenc}

\begin{document} \begin{itemize} \item Define $N$ to be the largest non-negative integer such that $k\times 4^{H-1}<\max(f(X(t);4,3), f(X(t);5,7))$. If $f(X(t);0,-1)>k\times 4^{H-1}$ and blablabla blablabla blablabla blablabla blablabla.

\item Define $N$ to be the largest non-negative integer such that $k\times 4^{H-1}<\max(f(X(t);4,3),\allowbreak f(X(t);5,7))$. If $f(X(t);0,-1)>k\times 4^{H-1}$ and blablabla blablabla blablabla blablabla blablabla. \end{itemize} \end{document}

Mico
  • 506,678