[LyX/master] LaTeXName tag for counters. Layout format change.
Richard Kimberly Heck
rikiheck at lyx.org
Sat Dec 5 21:19:36 UTC 2020
commit ae2ce7a86a1c2cbb9478195ddc7d8d1d53150211
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date: Sat Dec 5 16:14:30 2020 -0500
LaTeXName tag for counters. Layout format change.
---
lib/doc/Customization.lyx | 50 ++++++++++++++++++++++++++++++++++++++++-
lib/scripts/layout2layout.py | 7 ++++-
src/Counters.cpp | 22 ++++++++++++++++++
src/Counters.h | 6 +++++
src/TextClass.cpp | 2 +-
5 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index bdb1368..cb03821 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -138,6 +138,7 @@ logicalmkup
\docbook_table_output 0
\author -970929547 "Thibaut Cuvelier"
\author -712698321 "Jürgen Spitzmüller"
+\author -584632292 "Richard Kimberly Heck"
\author -495245474 "Jean-Marc Lasgouttes"
\author 5863208 "ab"
\author 232239728 "Owner"
@@ -22876,8 +22877,8 @@ string
\end_inset
-=
-\begin_inset Quotes erd
+=
+\begin_inset Quotes eld
\end_inset
@@ -22895,6 +22896,51 @@ LabelString
\end_inset
, but for use in the Appendix.
+\change_inserted -584632292 1607202551
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -584632292 1607202682
+\begin_inset Flex Code
+status open
+
+\begin_layout Plain Layout
+LaTeXName
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -584632292 1607202576
+string
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+ =
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+] The counter name as used in \SpecialChar LaTeX
+.
+ (E.g., in \SpecialChar LyX
+, there is a counter named `theorem', but it is output to \SpecialChar LaTeX
+ as `thm'.)
+\change_unchanged
+
\end_layout
\begin_layout Description
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index b2393ea..0a1edde 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -11,7 +11,7 @@
# This script will update a .layout file to current format
# The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 88
+currentFormat = 89
# Incremented to format 4, 6 April 2007, lasgouttes
@@ -301,6 +301,9 @@ currentFormat = 88
# Incremented to format 88, 28 November 2020 by tcuvelier
# New tag DocBookNotInPara.
+# Incremented to format 89, 5 December 2020 by rkh
+# New tag LaTeXName for counters
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
@@ -551,7 +554,7 @@ def convert(lines, end_format):
i += 1
continue
- if 87 <= format <= 88:
+ if 87 <= format <= 89:
# nothing to do.
i += 1
continue
diff --git a/src/Counters.cpp b/src/Counters.cpp
index 6376b64..a955d02 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -59,6 +59,7 @@ bool Counter::read(Lexer & lex)
CT_PRETTYFORMAT,
CT_INITIALVALUE,
CT_GUINAME,
+ CT_LATEXNAME,
CT_END
};
@@ -68,6 +69,7 @@ bool Counter::read(Lexer & lex)
{ "initialvalue", CT_INITIALVALUE},
{ "labelstring", CT_LABELSTRING },
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
+ { "latexname", CT_LATEXNAME },
{ "prettyformat", CT_PRETTYFORMAT },
{ "within", CT_WITHIN }
};
@@ -120,6 +122,10 @@ bool Counter::read(Lexer & lex)
lex.next();
guiname_ = lex.getDocString();
break;
+ case CT_LATEXNAME:
+ lex.next();
+ latexname_ = lex.getDocString();
+ break;
case CT_END:
getout = true;
break;
@@ -374,6 +380,22 @@ docstring const & Counters::guiName(docstring const & cntr) const
}
+docstring const & Counters::latexName(docstring const & cntr) const
+{
+ CounterList::const_iterator it = counterList_.find(cntr);
+ if (it == counterList_.end()) {
+ lyxerr << "step: Counter does not exist: "
+ << to_utf8(cntr) << endl;
+ return empty_docstring();
+ }
+
+ docstring const & latexname = it->second.latexName();
+ if (latexname.empty())
+ return cntr;
+ return latexname;
+}
+
+
void Counters::reset()
{
appendix_ = false;
diff --git a/src/Counters.h b/src/Counters.h
index ecd6853..7a82df4 100644
--- a/src/Counters.h
+++ b/src/Counters.h
@@ -69,6 +69,8 @@ public:
docstring const & prettyFormat() const { return prettyformat_; }
///
docstring const & guiName() const { return guiname_; }
+ ///
+ docstring const & latexName() const { return latexname_; }
/// Returns a map of LaTeX-like strings to format the counter.
/** For each language, the string is similar to what one gets
@@ -101,6 +103,8 @@ private:
docstring prettyformat_;
///
docstring guiname_;
+ /// The name used for the counter in LaTeX
+ docstring latexname_;
/// Cache of the labelstring with \\the<counter> expressions expanded,
/// indexed by language
mutable StringMap flatlabelstring_;
@@ -177,6 +181,8 @@ public:
std::string const & lang) const;
///
docstring const & guiName(docstring const & cntr) const;
+ ///
+ docstring const & latexName(docstring const & cntr) const;
/// Are we in appendix?
bool appendix() const { return appendix_; }
/// Set the state variable indicating whether we are in appendix.
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index a58ae6d..5b69be6 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -59,7 +59,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 88; // tcuvelier: add DocBookNotInPara
+int const LAYOUT_FORMAT = 89; // rkh: LaTeXName for counters
// Layout format for the current lyx file format. Controls which format is
More information about the lyx-cvs
mailing list