如何避免使用 wraptable 时出现 \hbox 未满警告

如何避免使用 wraptable 时出现 \hbox 未满警告

我曾尝试在我的论文中加入一个可包装表格,但是表格上方的段落之一被不必要地“拉长”了——我猜这与我收到的警告“段落中的 \hbox(badness 10000)未满(第 10000 行)”有关?

有什么想法可以避免这种情况吗?我正在用 pdfLaTeX 进行编译。

文本代码:

Even though Russia still utilises 'old media channels' (e.g. television, radio and 
newspapers) to reach both its domestic audience and audiences outside of its national 
borders, the reach is limited to Russian speaking minorities abroad. Thus, the Russian
state relies heavily on social media to reach non-Russian speaking audiences in the 
West (\citeauthor{ramsay2019weaponising}, \citeyear{ramsay2019weaponising}). 
\input{Images/Tables/SoMe platforms}Examining how Russia utilises the possibilities of
social media platforms is therefore an important area of research for disciplines such as 
political science, international studies, media and communication etc.

表格代码:

\begin{wraptable}{r}{3.9cm}

\captionsetup{justification=centering}
\vspace{-3.3mm}
\footnotesize
\begin{threeparttable}
\caption{\label{SoMe platforms}\\Most popular platforms}

{\renewcommand{\arraystretch}{0.9}
\begin{tabular}{cc} \hline \hline 
Platform & Active users \\ \hline
Facebook & 2,853 \\
YouTube & 2,291 \\
WhatsApp & 1,386 \\ 
Instagram & 1,386 \\
WeChat & 1,242 \\ 
TikTok & 732 \\ 
Telegram & 550 \\ 
Sina Weibo & 530 \\ 
Snapchat & 514 \\ 
Pinterest & 478 \\ 
Reddit & 430 \\ 
Twitter & 397 \\ \hline
\end{tabular}}

\begin{tablenotes}[flushleft] \vspace{-0.2cm}
\item{Note: Counted in millions}.\vspace{-0.15cm}
\item{Source: \citeauthor{StatistaB} (\citeyear{StatistaB})}.\vspace{0.1cm}
    \end{tablenotes}
\end{threeparttable}
\vspace{-3.5mm}
\end{wraptable}

序言代码:

\documentclass[oneside]{article}

%%%% Packages
\usepackage[T1,T2A]{fontenc} % Selv tilføjet
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\babeltags{ru=russian, en=english}
\usepackage{blindtext}
\usepackage{footnote}
\usepackage{csquotes}
\usepackage[style=apa, citestyle=apa, sorting=nyt ]{biblatex}
\addbibresource{Biblo.bib}
\usepackage{eso-pic} 
\usepackage{graphicx}
\usepackage[a4paper, hmargin={2.5cm, 3cm}, vmargin={3cm, 3cm}]{geometry}
\usepackage{fancyhdr}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{marginnote}
\usepackage{threeparttable}
\usepackage[font=small,format=plain,labelfont=bf,textfont=normal,justification=justified,singlelinecheck=false]{caption}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{float}
\pagestyle{fancy}
\usepackage{etoolbox}\apptocmd\appendix{\pretocmd\section{\clearpage}{}{}}{}{}
\usepackage{subfiles} 

% Extra packages
\usepackage[T1]{fontenc}
\usepackage{bmpsize}
\usepackage{topcapt}
\usepackage{booktabs}
\usepackage{wrapfig}
\usepackage{url}
\usepackage{ragged2e}

% Commands
\setstretch{1.25}
\newcommand{\margmod}[1]{\marginnote{\setstretch{.5}\parbox[t]{\marginparwidth}{\raggedright\emph{#1}}}}

%%%% Front page % ændrer senere!
\def \ColourPDF {Images/Metaimages/Front page_Political Science.pdf}
\def \TitlePDF   {Images/Metaimages/Front page_Political Science.pdf}

\author{
  \LARGE{My full name} \\
  \vspace{0cm} \\
  {Academic Supervisor: Add name} \\
  \vspace{.5cm} \\
}

\title{
  \vspace{3mm}
  \Huge{Master's Thesis}\\
  \vspace{18mm}
  \LARGE{Enter title name}
  \vspace{90mm}
}

\date{March 2022}

%%%% Layout style
\linespread{1.5}
\fancyhead[L]{} 
\fancyhead[R]{\slshape \rightmark}
\setlength{\parskip}{1em}

%%%% Front page layout
\begin{document}

\pagenumbering{roman}

\AddToShipoutPicture*{\put(0,602){\includegraphics*[viewport=0 600 700 1600]{\ColourPDF}}}
\AddToShipoutPicture*{\put(0,0){\includegraphics*{\TitlePDF}}}

\clearpage\maketitle 
\thispagestyle{empty}

\newpage

%%%% Meta info
%\begin{table}[!ht]
\begin{table}[!h]
\begin{tabular}{lll}
\vspace{5mm}
 \textbf{University} & & {University of Copenhagen} \\
 \vspace{5mm}
 \textbf{Name of Department} & & {Department of Political Science} \\
 \vspace{5mm}
 \textbf{Study Programme} & & {Master of Science (MSc) in Political Science} \\ 
 \vspace{5mm}
 \textbf{Author} & & {My full name} \\ 
 \vspace{5mm}
 \textbf{Student ID} & & {Add ID} \\
 \vspace{5mm}
 \textbf{Academic Supervisor} & & {Add name} \\
 \textbf{Title} & & {Title - line 1} \vspace{0.5mm}
\cr & & {Title - line 2} 
\\ \\
 \textbf{Date of Submission} & & {Add date} \\ 
\\
 \textbf{ECTS} & & {30} \\
\end{tabular}
\end{table}

\newpage

Start of paper..

输出的屏幕截图:

截屏

附录:

更新序言:

\documentclass[oneside]{article}

%%%% Packages
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\babeltags{ru=russian, en=english}
\usepackage{blindtext}
\usepackage{footnote}
\usepackage{csquotes}
\usepackage[style=apa, citestyle=apa, sorting=nyt ]{biblatex}
\addbibresource{Biblo.bib}
\usepackage{eso-pic} 
\usepackage{graphicx}
\usepackage[a4paper, hmargin={2.5cm, 3cm}, vmargin={3cm, 3cm}]{geometry}
\usepackage{fancyhdr}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{marginnote}
\usepackage{threeparttable}
\usepackage[font=small,format=plain,labelfont=bf,textfont=normal,justification=justified,singlelinecheck=false]{caption}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{float}
\pagestyle{fancy}
\usepackage{etoolbox}\apptocmd\appendix{\pretocmd\section{\clearpage}{}{}}{}{}
\usepackage{subfiles} 

% Extra packages
\usepackage[T1]{fontenc}
\usepackage{bmpsize}
\usepackage{topcapt}
\usepackage{booktabs}
\usepackage{microtype}   % <--- new
\usepackage{wrapfig}
\usepackage{tabularray} % <--- new
\UseTblrLibrary{booktabs, siunitx, varwidth} % <--- new
\usepackage{url}
\usepackage{ragged2e}

Tabularray 包: 在此处输入图片描述

测试 Zarko 提出的解决方案的编译时的输出: 在此处输入图片描述

答案1

编辑: 在 MWE 中,现在被视为所提供文档序言的相关部分。wraptable现在也插入到段落中间。

  • 您应该提供 MWE(最小工作示例),一个小但完整的文档示例,它可以重现您的问题(例如,参见下面的 MWE)

  • 和:

    • 添加跨文本行数选项
    • 稍微wraptable宽一点,
    • wraptable对于使用包中的表tabularray及其库booktabssiunitx(调用同名包)以及varwidth(特定于tabularray,用于测量单元格宽度)。

    编辑后的 ​​MWE 生成内容如下:

在此处输入图片描述

\documentclass{article}
\usepackage[a4paper, 
            hmargin={2.5cm, 3cm}, 
            vmargin={3cm, 3cm}]{geometry}
\usepackage{blindtext}% For dummy text. Don't use in a real document

\usepackage{microtype}   % <--- new
\usepackage{wrapfig}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, varwidth}
\usepackage[style=apa, 
            citestyle=apa, 
            sorting=nyt ]{biblatex}

\begin{document}
Even though Russia still utilises 'old media channels' (e.g. television, radio and newspapers) to reach both its domestic audience and audiences outside of its national borders, the reach is limited to Russian speaking minorities abroad. Thus, the Russian state relies heavily on social media to reach non-Russian speaking audiences in the West (\citeauthor{ramsay2019weaponising}, \citeyear{ramsay2019weaponising}). 
%
\input{wraptable.txt} % if it is in the same folder as document
%
Examining how Russia utilizes the possibilities of social media platforms is therefore an important area of research for disciplines such as political science, international studies, media and communication etc.

\blindtext

\blindtext
\end{document}

其中wrapfig文件包含:

\begin{wraptable}[18]{r}{45mm}
    \sisetup{table-format=4.0,
             group-minimum-digits=4,
             group-separator={,}
             }
    \SetTblrStyle{caption-tag}{font=\footnotesize\bfseries}
    \SetTblrStyle{caption-text}{font=\footnotesize}
\small
    \begin{talltblr}[
caption={Most popular platforms},
  label={SoMe platforms},
remark{Note}    = {Counted in millions},
remark{Source}  = {\citeauthor{StatA}, \citeyear{StatB}}
                    ]{colspec={ X[l,m] Q[c,m, si] },
                      rowsep = {0pt},
                      row{1} = {font=\bfseries, rowsep=2pt},
                      measure=vbox
                     }
    \toprule
Platform    & {{{Active  
                 users}}}   \\ 
    \midrule
Facebook    & 2 853         \\
YouTube     & 2 291         \\
WhatsApp    & 1 386         \\
Instagram   & 1 386         \\
WeChat      & 1 242         \\
TikTok      &   732         \\
Telegram    &   550         \\
Sina Weibo  &   530         \\
Snapchat    &   514         \\
Pinterest   &   478         \\
Reddit      &   430         \\
Twitter     &   397         \\ 
    \bottomrule
    \end{talltblr}
\end{wraptable}

编译没有错误,有九个关于biblatex包和参考书目项目的警告(因为参考书目未知),没有任何警告Bad Boxes(关于underfull hbox)。

在测试中我使用了最新版本的 MiKTeX。

附录:

正如@John Kormylo在下面的评论中提到的,上面的解决方案意外地起作用了,因为插入点之前的行中的文本在右文本边框处结束。如果不是,则此文本行将拉伸到边框。结果非常丑陋(这似乎是OP的主要问题)。

  • 这可以通过在两个单词之间移动插入点来解决,其中有一个自然的换行符。请参阅@Donald Arseneau 的回答问题
  • 另一种可能性是使用insboxTeX 中定义的宏:
\documentclass{article}
\usepackage[a4paper, 
            hmargin={2.5cm, 3cm}, 
            vmargin={3cm, 3cm}]{geometry}
\usepackage{blindtext}% For dummy text. Don't use in a real document

\usepackage{microtype}
\input{insbox}%%%%%%%%%%%%%% TeX macro, instead of wrapfig

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, varwidth}
\usepackage[skip=1ex, 
            font=small, 
            labelfont=bf, labelsep=newline]{caption}
\usepackage[style=apa, 
            citestyle=apa, 
            sorting=nyt ]{biblatex}

\begin{document}

\InsertBoxR{3}{\input{wraptable.txt}}[9]
Even though Russia still utilizes 'old media channels' (e.g. television, radio and newspapers) to reach both its domestic audience and audiences outside of its national borders, the reach is limited to Russian speaking minorities abroad. Thus, the Russian state relies heavily on social media to reach non-Russian speaking audiences in the West (\citeauthor{ramsay2019weapon}, \citeyear{ramsay2019weapon}). Examining how Russia utilises the possibilities of social media platforms is therefore an important area of research for disciplines such as political science, international studies, media and communication etc.

\blindtext[1]

\blindtext[1]
\end{document}

其中wraptable.txt更改为:

\begin{minipage}{46mm}
\vspace*{0.5\baselineskip}\hfill
    \sisetup{table-format=4.0,
             group-minimum-digits=4,
             group-separator={,}
             }
    \SetTblrStyle{caption-tag}{font=\footnotesize\bfseries}
    \SetTblrStyle{caption-text}{font=\footnotesize}
\small
    \begin{talltblr}[
caption={Most popular platforms},
  label={SoMe platforms},
remark{Note}    = {Counted in millions},
remark{Source}  = {\citeauthor{StatA}, \citeyear{StatB}}
                    ]{width=44mm,
                      colspec={ X[l,m] Q[c,m, si] },
                      rowsep = {0pt},
                      row{1} = {font=\bfseries, rowsep=2pt},
                      measure=vbox
                     }
    \toprule
Platform    & {{{Active
                 users}}}   \\
    \midrule
Facebook    & 2 853         \\
YouTube     & 2 291         \\
WhatsApp    & 1 386         \\
Instagram   & 1 386         \\
WeChat      & 1 242         \\
TikTok      &   732         \\
Telegram    &   550         \\
Sina Weibo  &   530         \\
Snapchat    &   514         \\
Pinterest   &   478         \\
Reddit      &   430         \\
Twitter     &   397         \\
    \bottomrule
    \end{talltblr}
\end{minipage}

在此处输入图片描述

相关内容