# How to fit a line in latex?

\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
%\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}

Let $G$ be a $3$-coloured digraph. A subgraph $\mathrm{H}$ of $G$ is called linear if each component of $\mathrm{H}$ is either an edge or a cycle. We call a component of a linear subgraph {\em nonsingular}, if it is a cycle having weight other than $1$. All other components, that is, a cycle of weight $1$ and an edge of any weight, are singular (Laplacian singular, see \cite{DS2}). We use $C_{\mathrm{H}}$ to denote the number of cycles in a linear subgraph $\mathrm{H}$. By $S_{\mathrm{H}}$ and $N_{\mathrm{H}}$, we denote the number of singular components and the number of nonsingular components in $\mathrm{H}$, respectively. By $\mathcal{C}_k$, we will denote the set $\{\mathrm{H}\mid\mathrm{H} \mbox{ is a linear subgraph of order } k \mbox{ of } G \mbox{ in which no cycle has weight } \pm\mathrm{i}\}$.

\end{document}


Here in the text, when I compile the last line goes outside the box. How to fit this line so that text does not go outside?

• You should not use \mboxes like \mbox{ in which no cycle has weight }. – Schrödinger's cat Feb 16 at 6:58
• but if I remove it all the words get combined together (looks like '' isalinearsubgra pho f orderk'') – J.Doe Feb 16 at 7:03
• My guess would be to use \text instead – Simon Feb 16 at 7:10
• I had tried with that also. But still it remains the same – J.Doe Feb 16 at 7:13
• Could you show a picture of the problem, as I don't get any issues with your code. – Simon Feb 16 at 7:33

\mbox and \text will not text-wrap, use $..$s for math parts only.

\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
%\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}

Let $G$ be a $3$-coloured digraph. A subgraph $\mathrm{H}$ of $G$ is called linear if
each component of $\mathrm{H}$ is either an edge or a cycle. We call a component of a
linear subgraph {\em nonsingular}, if it is a cycle having weight other than $1$. All
other components, that is, a cycle of weight $1$ and an edge of any weight, are singular
(Laplacian singular, see \cite{DS2}). We use $C_{\mathrm{H}}$ to denote the number of
cycles in a linear subgraph $\mathrm{H}$. By $S_{\mathrm{H}}$ and $N_{\mathrm{H}}$, we
denote the number of singular components and the number of nonsingular components in
$\mathrm{H}$, respectively. By $\mathcal{C}_k$, we will denote the set
\{$\mathrm{H}\mid\mathrm{H}$ is a linear subgraph of order $k$ of $G$ in which no
cycle has weight $\pm\mathrm{i}$\}.

\end{document}


• it is very nice... – J.Doe Feb 16 at 7:56
• Why \{ and \} outside of math mode? – egreg Feb 16 at 8:34
• Better use $$...$$ to enclose inline math, it helps avoiding accidents (unclosed $gets closed by an unrelated open$) and it easier to frob with regex tools. – vonbrand Feb 17 at 3:33

Just don't use such verbose set descriptions: your readers will have a hard time guessing where the set description starts and ends.

In the code below I added several ties ~.

\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
%\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}

Let $G$ be a $3$-coloured digraph. A subgraph $\mathrm{H}$ of $G$ is called
linear if each component of $\mathrm{H}$ is either an edge or a cycle.
We call a component of a linear subgraph \emph{nonsingular}, if it is a cycle
having weight other than~$1$. All other components, that is, a cycle of
weight~$1$ and an edge of any weight, are singular (Laplacian singular,
see~\cite{DS2}). We use $C_{\mathrm{H}}$ to denote the number of cycles in
a linear subgraph~$\mathrm{H}$. By $S_{\mathrm{H}}$ and $N_{\mathrm{H}}$
we denote the number of singular components and the number of nonsingular
components in~$\mathrm{H}$, respectively. By~$\mathcal{C}_k$ we will denote
the set
%%% $\{\mathrm{H}\mid\mathrm{H} \mbox{ is a linear subgraph of order } k %%%\mbox{ of } G \mbox{ in which no cycle has weight } \pm\mathrm{i}\}$.
of all linear subgraphs of~$G$ having order~$k$ and in which no cycle has
weight~$\pm\mathrm{i}$.

\end{document}


Note also \emph{nonsingular} rather than {\em nonsingular}. I'm not sure why the graph symbol is in italic, while the symbol for a subgraph is upright.

Do you need a comma after By~$\mathcal{C}_k$? Grammar would say no.

• Much easier to read! – Benjamin McKay Feb 16 at 14:35
• Just a nit to pick: when defining something, emphasize (like "... is called \emph{linear}..."). – vonbrand Feb 17 at 3:35
• @vonbrand The OP used it for another term; whether using \emph for “linear” depends on the text preceding the present paragraph, but you’re probably right. – egreg Feb 17 at 8:49