arXiv / html_feedback

Supports a student project developing a UI for feedback on arXiv articles rendered as html.
MIT License
18 stars 3 forks source link

lstlisting environment does not preservere leading whitespace #2201

Open niklas-uhl opened 2 months ago

niklas-uhl commented 2 months ago

Description

When using the lstlisting environment from the listings package, indentation is not preserved. See Fig. 1. The TeX source is:

\begin{figure}[t]
    \begin{lstlisting}[
basicstyle=\ttfamily\scriptsize,
emph={[2]send_buf, send_counts, recv_counts_out, recv_displs_out},
emphstyle={[2]\color{gray}},
commentstyle=\textcolor{my-dark-red},
emph={[3]vector, std, exclusive_scan, move},
emphstyle={[3]\color{my-purple}},
escapechar=!
]
std::vector<double> v = {...};
// KaMPIng allows concise code
// with sensible defaults ... (1)
auto v_global = comm.allgatherv(send_buf(v));

// ... or detailed tuning of each parameter (2)
std::vector<int> rc;
auto [v_global, rcounts, rdispls] = comm.allgatherv(
 send_buf(v), //(3)
 recv_counts_out<resize_to_fit/*(6)*/>(std::move(rc)), //(4)
 recv_displs_out() //(5)
);
  \end{lstlisting}
  \caption{\kamping offers a high-level easy-to-use interface (1) and full control over each parameter (2). Data types and buffer sizes can be automatically inferred (3). Arguments allow passing by reference or by value and transferring data ownership via move semantics (4). Out-parameters allow controlling which default-computed parameters are returned to the user (5). Resize policies allow controlling memory allocation (6).}
  \label{fig:kamping-intro}
\end{figure}

(Optional:) Please add any files, screenshots, or other information here.

Screenshot from 2024-09-27 13-32-39

(Required) What is this issue most closely related to? Select one.

Figures

Internal issue ID

4912f6dc-7853-475f-aa5d-89a87ab4de15

Paper URL

https://arxiv.org/html/2404.05610v3

Browser

Chrome/128.0.0.0

Device Type

Desktop

github-actions[bot] commented 2 months ago

Hello @niklas-uhl, thanks for the issue report! We are reviewing your report and will address it as soon as possible.

xworld21 commented 2 months ago

@dginev I recognise this issue, and it comes from CSS: the white-space property of .ltx_text is accidentally overriding the one of .ltx_lst_space. If you restore white-space: pre, the indentation reappears.

dginev commented 2 months ago

@xworld21 oh, you're spot on!

This indents fine in ar5iv now that you mention it (https://ar5iv.labs.arxiv.org/html/2404.05610), although I believe that's an older version of the article at the moment.

So it should be quite an easy fix.