Compilation-based text editors, such as Overleaf for enable users to insert text alongside commands, which are then compiled into a formatted document such as a PDF. A major drawback of these editors is the inability to preview the final document layout without compiling. Consequently, users often resort to trial-and-error methods to condense documents to meet space constraints, making changes in the text editor and repeatedly compiling to check whether the document fits the required space. In addition, space-saving modifications may compromise the readability of the document. For example, reducing the size of a figure by 50% can render it unreadable. In this paper, we formally define the problem of optimizing document layout to fit space constraints while minimizing the magnitude of layout modifications and thereby reducing the likelihood of harming readability. To address this challenge, we propose an automated decision-support system that employs machine learning models to estimate the space saved by specific adjustments. This system provides recommendations for modifications that optimize space usage while favoring smaller geometric changes, with final readability and layout quality verified separately. To evaluate the quality and real-world applicability of our algorithms, we conducted extensive experiments. First, we tested our algorithms on a dataset of 329,000 generated files, achieving improved reductions in document length compared with baseline heuristics. To assess applicability to real-world scenarios, we further evaluated our algorithms on 140 articles accepted to AAAI and obtained from arXiv. These experiments show that, in this benchmark setting, the proposed method achieves the best observed performance among the compared approaches, with moderate but consistent improvements over simpler methods and heuristics.
Roshanski et al. (Wed,) studied this question.