如何修复枚举中的 URL 过满或不足问题?

如何修复枚举中的 URL 过满或不足问题?

在几个问题的答案的支持下,我能够从我的枚举引用框中删除几个警告,但这个警告除外:

test.tex:41: Underfull \hbox (badness 2913) in paragraph at lines 41--42

Underfull \hbox (badness 2913) in paragraph at lines 41--42
[]\T1/cmr/m/n/12 Google []$\T1/cmtt/m/n/12 http : / / directory . google . com 
/ Top / Computers / Programming /

以下是我latexmk -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make test.tex使用 MikTex 版本进行编译的方法:

pdflatex --version
MiKTeX-pdfTeX  (MiKTeX 2.9.6300)

using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.53.1; using libcurl/7.53.1 WinSSL
compiled with expat version 2.2; using expat_2.2.0
compiled with jpeg version 9.2
compiled with liblzma version 50020032; using 50020032
compiled with libpng version 1.6.29; using 1.6.29
compiled with libressl version LibreSSL 2.4.5; using LibreSSL 2.4.5
compiled with MiKTeX Application Framework version 1.6300; using 1.6300
compiled with MiKTeX Core version 1.6300; using 1.6300
compiled with MiKTeX Archive Extractor version 1.6300; using 1.6300
compiled with MiKTeX Package Manager version 1.6300; using 1.6300
compiled with poppler version 0.53.0
compiled with uriparser version 0.8.4
compiled with zlib version 1.2.11; using 1.2.11

这是最小代码:

\documentclass[12pt]{article}

\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{array,ragged2e}
\usepackage[shortlabels]{enumitem}

% Change background color for text block
% https://tex.stackexchange.com/questions/238294/change-background-color-for-text-block
\usepackage{framed}
\usepackage[most]{tcolorbox}
\definecolor{shadecolor}{RGB}{219, 229, 241}
\newtcolorbox{myquote}{
colback=shadecolor,
grow to right by=-2mm,
grow to left by=-2mm,
boxrule=0pt,
boxsep=0pt,
breakable
}

% https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}

% https://tex.stackexchange.com/questions/261776/how-to-avoid-overfull-error-with-url-package
\Urlmuskip=0mu plus 2mu

\begin{document}

    \begin{myquote}
    \begin{enumerate}[nolistsep,leftmargin=*]

        \sloppy
        \item {\RaggedRight Free \url{http://members.magnet.at/johann.langhofer/products/jxbeauty/overview.html} (has JBuilder support) }

        \item {\RaggedRight Google \url{http://directory.google.com/Top/Computers/Programming/Languages/Java/Development_Tools/Code_Beautifiers/?tc=1} }

    \end{enumerate}
    \end{myquote}

\end{document}

PDF 版本如下所示:

在此处输入图片描述

答案1

你的\RaggedRight用法是错误的(所以它什么也没做)你想要

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{array,ragged2e}
\usepackage[shortlabels]{enumitem}

% Change background color for text block
% https://tex.stackexchange.com/questions/238294/change-background-color-for-text-block
\usepackage{framed}
\usepackage[most]{tcolorbox}
\definecolor{shadecolor}{RGB}{219, 229, 241}
\newtcolorbox{myquote}{
colback=shadecolor,
grow to right by=-2mm,
grow to left by=-2mm,
boxrule=0pt,
boxsep=0pt,
breakable
}

% https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}

% https://tex.stackexchange.com/questions/261776/how-to-avoid-overfull-error-with-url-package
\Urlmuskip=0mu plus 2mu

\begin{document}

    \begin{myquote}\RaggedRight
    \begin{enumerate}[nolistsep,leftmargin=*]

        \sloppy
        \item  Free \url{http://members.magnet.at/johann.langhofer/products/jxbeauty/overview.html} (has JBuilder support) 

        \item Google \url{http://directory.google.com/Top/Computers/Programming/Languages/Java/Development_Tools/Code_Beautifiers/?tc=1} 

    \end{enumerate}
    \end{myquote}

\end{document}

正如您所做的那样,您在段落结束之前完成了该组,因此所有不规则的设置都被恢复,并且使用默认设置将段落设置为完全对齐。

相关内容