From fe43d034483a779fc13ed56343dccd05a5247f40 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 18 Aug 2024 09:59:37 +0200 Subject: [PATCH] Assure widest nomencl label is encodable --- src/insets/InsetNomencl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index 36471a1026..4adcded1f8 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -448,11 +448,18 @@ void InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in if (autowidth || getParam("set_width") == "textwidth") { docstring widest = autowidth ? nomenclWidest(buffer()) : getParam("width"); + // We need to validate that all characters are representable + // in the current encoding. If not try the LaTeX macro which might + // or might not be a good choice, and issue a warning. + pair widest_latexed = + runparams.encoding->latexString(widest, runparams.dryrun); + if (!widest_latexed.second.empty()) + LYXERR0("Uncodable character in nomencl entry. List width might be wrong!"); // Set the label width via nomencl's command \nomlabelwidth. // This must be output before the command \printnomenclature - if (!widest.empty()) { + if (!widest_latexed.first.empty()) { os << "\\settowidth{\\nomlabelwidth}{" - << widest + << widest_latexed.first << "}\n"; } } else if (getParam("set_width") == "custom") { -- 2.39.5