1

I have tried to include a wraptable in my paper, but one of the paragraphs above the table is unnecessarily "stretched" - something I guess is related to the warning "Underfull \hbox (badness 10000) in paragraph at lines.." that I also get?

Any idea how I can avoid this? I am compiling in pdfLaTeX.

Code for the text:

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.

Code for the table:

\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}

Code for preamble:

\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..

Screnshot of the output:

Screenshot

Addendum:

Updated preamble:

\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 package: enter image description here

Output when testing the compilation of proposed solution by Zarko: enter image description here

11
  • Please extend your code fragment to complete, compilable document.
    – Zarko
    Feb 15, 2022 at 7:14
  • Sure! I have extended the code now. Would you still recommend your suggestions below after having seen my preamble?
    – Nicolai MC
    Feb 15, 2022 at 16:01
  • I tried implementing your suggestions below, but it didn't work out very well for me - the output ended up even more messier. The \UseTblrLibrary package seemed to cause the issues.
    – Nicolai MC
    Feb 15, 2022 at 16:03
  • Which version of tabularray you have installed? With 2021Q it should work as advertised ;-). See addendum to my answer,
    – Zarko
    Feb 15, 2022 at 17:03
  • Hm, how can I check the version? :) I get the error "Environment tallblr undefined". See addendum to my answer.
    – Nicolai MC
    Feb 17, 2022 at 7:26

1 Answer 1

2

Edit: In MWE are now considered relevant part of provided document preamble. Also wraptable is now inserted in the middle of paragraph.

  • you should provide MWE (Minimal working Example), a small, but complete document example, which reproduce your problem (as example see my MWE below))

  • With:

    • adding option for number of spanning text lines
    • make wraptable a bit wider, and
    • for table in wraptable use tabularray package with its libraries booktabs and siunitx (which call packages of the same names), and varwidth (specific to tabularray, needed for measuring of cells widths).

    Compilation of edited MWE produce:

enter image description here

\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}

where wrapfig file contain:

\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}

Compilation gives no errors, nine Warnings concerning biblatex package and referencing of bibliography items (since bibliography is unknown), no any Bad Boxes (concerning underfull hbox).

In test I use recent version of MiKTeX.

Addendum:

As mentioned @John Kormylo in his comment below, above solution woks by accidentally because the text in line before inserting point end at right text border. If not, this text line is stretched to the border. Result is very ugly (and seems that this is main OP problem).

  • This can be solved by move inserting point between two words where there is a natural line break.. See @Donald Arseneau answer on question.
  • Another possibility is use insbox macro defined in TeX:
\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}

where wraptable.txt is changed to:

\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}

enter image description here

points

3
  • I get the impression that you mostly just got lucky in the word spacing so that the wraptable wound up at the end of a line. A safer option would be to add a blank line or \par before starting wraprable. Feb 15, 2022 at 15:01
  • @JohnKormylo, you are right. wraptable or wrapfigure is not possible to insert in middle of paragraph (I forgot to emphasize this fact) . Solution is split this paragraph on two and eventually manually add few first word from the second paragraph. Yes, I was lucky ...
    – Zarko
    Feb 15, 2022 at 15:15
  • @JohnKormylo, see addendum to answer.
    – Zarko
    Feb 15, 2022 at 17:00

You must log in to answer this question.

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