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}
Mico
  • 506,678
  • 2
    Try {\footnotesize Source: \url{http://google.com/}\par}. – Henri Menke Sep 11 '17 at 02:53
  • Henri's approach is reasonable. But you could also try the sloppypar environment: https://tex.stackexchange.com/a/40521/35642 – thiagowfx Sep 11 '17 at 02: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 Sep 11 '17 at 03: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! :) – user3613919 Sep 11 '17 at 04:27
  • Sorry @koleygr for that. I will try reminding myself that while asking new question – user3613919 Sep 11 '17 at 04:40
  • No problem, I had it already created and found a review to accept but there where no real changes to your code... So I just added some lines. You don't have to try to remember... You have to get in the place of the one who try to help you when posting any question in any forum... It is sure that if he can easily reproduce your problem, you have more possibilities to make him try to solve... ... Just write what you would like to see to make you help... Wait some time (days) for @HenriMenke to make his comment a real answer and if he will not, please write and accept the answer you already have. – koleygr Sep 11 '17 at 05:04
  • @koleygr -- Excellent MWE! :-) – Mico Sep 11 '17 at 05:08
  • @thiagowfx - \sloppy (or \sloppypar) won't help here, as the argument of a \textsuperscript directive doesn't get line-broken. – Mico Sep 11 '17 at 05:19

1 Answers1

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}
Mico
  • 506,678