1

I use \texttt to format some text. I need to break it into two lines if it exceeds the line width. I use \justify but it does not always work. The script below shows two examples one works well and the other does not. Can you identify why \justify does not work in one case?

\documentclass[sigconf]{acmart}
\newcommand*\justify{%
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
  \hyphenchar\font=`\-% allowing hyphenation
}
\usepackage{lipsum}
\begin{document}
\title{Test}

\author{First Author}
\affiliation{%
  \institution{First University}
  \city{City}
  \state{Country}
}
\email{[email protected]}

\author{Second Author}
\affiliation{%
  \institution{Second University}
  \city{City}
  \state{Country}
}
\email{[email protected]}
\begin{abstract}
Abstract here.
\end{abstract}
\maketitle
\section{Section}
\lipsum

\texttt{\justify{xxxx:xxxx;yyyyyyyyy:yy-yy-yyyy;zzzzzzz:zz-zz-zzzz;uuu-uuuuu:uuuuuu-uuuuuu;aaaaaaaaaaaaaaaa:a;cccccc:c;wwwwww:[email protected]}}

\texttt{\justify{long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-}}

\end{document}
3
  • Which one works? The second one?
    – Marco
    Jun 21, 2018 at 6:53
  • 1
    note you have defined \justify with no argument so should be \justify xxx... not \justify{xxx....} Jun 21, 2018 at 7:07
  • Your first example has very few possible break points. Jun 21, 2018 at 7:24

1 Answer 1

2

enter image description here

\RequirePackage[hyphens]{url}
\documentclass[sigconf]{acmart}

\usepackage{lipsum}
\begin{document}
\title{Test}

\author{First Author}
\affiliation{%
  \institution{First University}
  \city{City}
  \state{Country}
}
\email{[email protected]}

\author{Second Author}
\affiliation{%
  \institution{Second University}
  \city{City}
  \state{Country}
}
\email{[email protected]}
\begin{abstract}
Abstract here.
\end{abstract}
\maketitle
\section{Section}
\lipsum

\begin{flushleft}

\path|xxxx:xxxx;yyyyyyyyy:yy-yy-yyyy;zzzzzzz:zz-zz-zzzz;uuu-uuuuu:uuuuuu-uuuuuu;aaaaaaaaaaaaaaaa:a;cccccc:c;wwwwww:[email protected]|

\path|long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-|

\end{flushleft}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .