From ce473c810a170503289a46c821c4b1df0902e9e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Thu, 21 May 2009 22:18:08 +0000 Subject: [PATCH] InsetNomencl.cpp: assure that the label width is never below the predefined value and that there is always enough space git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29773 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetNomencl.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index bc2e0bb00a..86eed23682 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -171,7 +171,6 @@ docstring nomenclWidest(Buffer const & buffer) int w = 0; docstring symb; InsetNomencl const * nomencl = 0; - ParagraphList::const_iterator it = buffer.paragraphs().begin(); ParagraphList::const_iterator end = buffer.paragraphs().end(); @@ -186,15 +185,18 @@ docstring nomenclWidest(Buffer const & buffer) continue; nomencl = static_cast(inset); docstring const symbol = nomencl->getParam("symbol"); + // we can only check for the number of characters, since it is + // impossible to get the info that "iiiii" is smaller than "WW" + // we therefore output w times "W" as string ("W" is always the + // widest character) int const wx = symbol.size(); - if (wx > w) { + if (wx > w) w = wx; - symb = symbol; - } } } - - // return the widest symbol + // return the widest symbol as w times a "W" + for (int n = 1; n <= w; ++n) + symb = symb + "W"; return symb; } @@ -202,12 +204,14 @@ docstring nomenclWidest(Buffer const & buffer) int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const { int lines = 0; - // this must be output before the command \printnomenclature docstring widest = nomenclWidest(buffer()); + // set the label width via nomencl's command \nomlabelwidth + // this must be output before the command \printnomenclature if (!widest.empty()) { - // set the label width via nomencl's command \nomlabelwidth - os << "\\settowidth{\\nomlabelwidth}{"; - os << widest <<"}\n"; + // assure that the width is never below the predefined value of 1 cm + os << "\\settowidth{\\nomlabelwidth}{" << widest <<"}\n"; + os << "\\ifthenelse{%\n \\lengthtest{\\nomlabelwidth < 1cm}}\n"; + os << " {\\setlength{\\nomlabelwidth}{1cm}}\n {}\n"; ++lines; } // output the command \printnomenclature @@ -219,6 +223,8 @@ int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const void InsetPrintNomencl::validate(LaTeXFeatures & features) const { features.require("nomencl"); + // needed for InsetPrintNomencl::latex + features.require("ifthen"); } -- 2.39.2