1

Hello I encountered a problem with breaking lines using package - \usepackage[hyphens]{url}.

It works perfectly in every situation expect this one where I use it in \textsuperscript{}. Unfortunately \textsuperscript{} was the only way found to include source with smaller font size below a picture.

Here is an example:

\documentclass{article}
\usepackage{graphicx}
\usepackage[hyphens]{url}

\begin{document}

\begin{figure}[!htb]
    \begin{center}
    \includegraphics[scale=0.64]{example-image-a}
    \textsuperscript{Source and some text to reproduce the problem of non-hyphenation: \url{http://google.com/}}
    \caption{Schema}
    \label{abc}
    \end{center}
\end{figure}

\end{document}
8
  • 2
    Try {\footnotesize Source: \url{http://google.com/}\par}. Commented Sep 11, 2017 at 2:53
  • Henri's approach is reasonable. But you could also try the sloppypar environment: tex.stackexchange.com/a/40521/35642
    – thiagowfx
    Commented Sep 11, 2017 at 2:55
  • 1
    Please try giving a real minimum working example at your questions. I edited just instead of accepting an edit with no changes...
    – koleygr
    Commented Sep 11, 2017 at 3:03
  • @Henri Menke Yea!! The size of the font is a bit bigger but still smaller than caption which resolves my problem. I really appreciate your help! :) Commented Sep 11, 2017 at 4:27
  • Sorry @koleygr for that. I will try reminding myself that while asking new question Commented Sep 11, 2017 at 4:40

1 Answer 1

2

\textsuperscript{} was the only way found to include source with smaller font size

Nothing in the argument of a \textsuperscript -- or, for that matter, \textsubscript -- directive is ever line-broken. And this observation pertains not just to URL strings that may occur in the argument of \textsuperscript.

Try a switch such as \footnotesize (20% linear reduction of font size) or \scriptsize (30% linear reduction) instead. Don't use \tiny unless you're prepared to distribute a magnifying glass with each copy of your document...

enter image description here

\documentclass{article}
\usepackage{graphicx}
% just for this example:
\usepackage[textwidth=10cm,showframe,nomarginpar]{geometry} 
\usepackage[hyphens]{url}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[scale=0.64]{example-image-a}

    {\scriptsize Source and some text to reproduce the problem 
     of non-hyphenation: \url{http://google.com/}\par}

    versus % this is typeset at "\normalsize"

    \textsuperscript{Source and some text to reproduce the problem 
     of non-hyphenation: \url{http://google.com/}}

    \caption{Schema} % the caption is also typeset at "\normalsize"
    \label{abc}
\end{figure}

\end{document}
0

You must log in to answer this question.

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