mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Support \caption* (bug #3209)
This was a low hanging fruit which would have to wait for a long time because of a file format change if it was not implemented before 2.1.
This commit is contained in:
parent
11e0d941a2
commit
c61ef8b205
@ -491,6 +491,16 @@ InsetLayout Caption:Standard
|
||||
End
|
||||
|
||||
|
||||
InsetLayout Caption:LongTableNoNumber
|
||||
CopyStyle Caption:Standard
|
||||
LatexName caption*
|
||||
Argument 1
|
||||
LabelString "Long Table Caption (unnumbered)"
|
||||
Tooltip "The caption as it appears in the list of tables"
|
||||
EndArgument
|
||||
End
|
||||
|
||||
|
||||
InsetLayout Preview
|
||||
LabelString Preview
|
||||
Decoration minimalistic
|
||||
|
@ -3161,7 +3161,6 @@ def convert_captioninsets(document):
|
||||
return
|
||||
document.body[i] = "\\begin_inset Caption Standard"
|
||||
i = i + 1
|
||||
|
||||
|
||||
|
||||
def revert_captioninsets(document):
|
||||
@ -3178,7 +3177,7 @@ def revert_captioninsets(document):
|
||||
|
||||
def convert_captionlayouts(document):
|
||||
" Convert caption layouts to caption insets. "
|
||||
|
||||
|
||||
caption_dict = {
|
||||
"Captionabove": "Above",
|
||||
"Captionbelow": "Below",
|
||||
@ -3187,7 +3186,7 @@ def convert_captionlayouts(document):
|
||||
"CenteredCaption" : "Centered",
|
||||
"Bicaption" : "Bicaption",
|
||||
}
|
||||
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_layout", i)
|
||||
@ -4080,6 +4079,20 @@ def revert_mbox_fbox(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def revert_starred_caption(document):
|
||||
" Reverts unnumbered longtable caption insets "
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Caption LongTableNoNumber", i)
|
||||
if i == -1:
|
||||
return
|
||||
# This is not equivalent, but since the caption inset is a full blown
|
||||
# text inset a true conversion to ERT is too difficult.
|
||||
document.body[i] = "\\begin_inset Caption Standard"
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -4140,10 +4153,12 @@ convert = [
|
||||
[465, [convert_lyxframes, remove_endframes]],
|
||||
[466, []],
|
||||
[467, []],
|
||||
[468, []]
|
||||
[468, []],
|
||||
[469, []]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[468, [revert_starred_caption]],
|
||||
[467, [revert_mbox_fbox]],
|
||||
[466, [revert_iwona_fonts]],
|
||||
[465, [revert_powerdot_flexes, revert_powerdot_pause, revert_powerdot_itemargs, revert_powerdot_columns]],
|
||||
|
@ -2527,13 +2527,12 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
case LFUN_CAPTION_INSERT: {
|
||||
code = CAPTION_CODE;
|
||||
bool varia = true;
|
||||
if (cur.depth() > 0) {
|
||||
if (&cur[cur.depth() - 1].inset()
|
||||
&& !cur[cur.depth() - 1].inset().allowsCaptionVariation())
|
||||
varia = false;
|
||||
}
|
||||
string arg = cmd.getArg(0);
|
||||
bool varia = arg != "LongTableNoNumber";
|
||||
if (cur.depth() > 0) {
|
||||
if (&cur[cur.depth() - 1].inset())
|
||||
varia = cur[cur.depth() - 1].inset().allowsCaptionVariation(arg);
|
||||
}
|
||||
// not allowed in description items,
|
||||
// and in specific insets
|
||||
enable = !inDescriptionItem(cur)
|
||||
|
@ -1634,16 +1634,18 @@ void MenuDefinition::expandCaptions(Buffer const * buf, bool switchcap)
|
||||
docstring const type = split(*cit, dummy, ':');
|
||||
docstring const trtype = translateIfPossible(type);
|
||||
docstring const cmitem = bformat(_("Caption (%1$s)"), trtype);
|
||||
if (switchcap)
|
||||
addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cmitem),
|
||||
FuncRequest(LFUN_INSET_MODIFY,
|
||||
from_ascii("changetype ")
|
||||
+ type), QString(), true));
|
||||
else
|
||||
captions.addWithStatusCheck(MenuItem(MenuItem::Command,
|
||||
toqstr(trtype),
|
||||
FuncRequest(LFUN_CAPTION_INSERT,
|
||||
type), QString(), true));
|
||||
// make menu item optional, otherwise we would also see
|
||||
// forbidden caption types
|
||||
if (switchcap)
|
||||
addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cmitem),
|
||||
FuncRequest(LFUN_INSET_MODIFY,
|
||||
from_ascii("changetype ")
|
||||
+ type), QString(), true));
|
||||
else
|
||||
captions.addWithStatusCheck(MenuItem(MenuItem::Command,
|
||||
toqstr(trtype),
|
||||
FuncRequest(LFUN_CAPTION_INSERT,
|
||||
type), QString(), true));
|
||||
}
|
||||
if (!captions.empty()) {
|
||||
MenuItem item(MenuItem::Submenu, qt_("Caption"));
|
||||
@ -1796,7 +1798,7 @@ struct Menus::Impl {
|
||||
/** The entries with the following kind are expanded to a
|
||||
sequence of Command MenuItems: Lastfiles, Documents,
|
||||
ViewFormats, ExportFormats, UpdateFormats, Branches,
|
||||
Indices, Arguments, SwitchArguments, Captions, Switchcaptions
|
||||
Indices, Arguments, SwitchArguments, Captions, SwitchCaptions
|
||||
*/
|
||||
void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
|
||||
BufferView const *) const;
|
||||
|
@ -351,7 +351,7 @@ public:
|
||||
/// can we click at the specified position ?
|
||||
virtual bool clickable(int, int) const { return false; }
|
||||
/// Move one cell backwards
|
||||
virtual bool allowsCaptionVariation() const { return false; }
|
||||
virtual bool allowsCaptionVariation(std::string const &) const { return false; }
|
||||
|
||||
/// does this contain text that can be change track marked in DVI?
|
||||
virtual bool canTrackChanges() const { return false; }
|
||||
|
@ -229,12 +229,11 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
if (first_arg == "changetype") {
|
||||
string const type = cmd.getArg(1);
|
||||
status.setOnOff(type == type_);
|
||||
bool varia = true;
|
||||
bool varia = type != "LongTableNoNumber";
|
||||
// check if the immediate parent inset allows caption variation
|
||||
if (cur.depth() > 1) {
|
||||
if (&cur[cur.depth() - 2].inset()
|
||||
&& !cur[cur.depth() - 2].inset().allowsCaptionVariation())
|
||||
varia = false;
|
||||
if (&cur[cur.depth() - 2].inset())
|
||||
varia = cur[cur.depth() - 2].inset().allowsCaptionVariation(type);
|
||||
}
|
||||
status.setEnabled(varia
|
||||
&& buffer().params().documentClass().hasInsetLayout(
|
||||
|
@ -470,6 +470,12 @@ void InsetFloat::setNewLabel()
|
||||
}
|
||||
|
||||
|
||||
bool InsetFloat::allowsCaptionVariation(std::string const & newtype) const
|
||||
{
|
||||
return !params_.subfloat && newtype != "LongTableNoNumber";
|
||||
}
|
||||
|
||||
|
||||
docstring InsetFloat::getCaption(OutputParams const & runparams) const
|
||||
{
|
||||
if (paragraphs().empty())
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
///
|
||||
InsetFloatParams const & params() const { return params_; }
|
||||
///
|
||||
bool allowsCaptionVariation() const { return !params_.subfloat; }
|
||||
bool allowsCaptionVariation(std::string const &) const;
|
||||
private:
|
||||
///
|
||||
docstring layoutName() const;
|
||||
|
@ -3480,6 +3480,13 @@ bool InsetTabular::insetAllowed(InsetCode code) const
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
|
||||
{
|
||||
return tabular.is_long_tabular &&
|
||||
(newtype == "Standard" || newtype == "LongTableNoNumber");
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::write(ostream & os) const
|
||||
{
|
||||
os << "Tabular" << endl;
|
||||
|
@ -854,6 +854,8 @@ public:
|
||||
insets that may contain several paragraphs */
|
||||
bool inheritFont() const { return false; }
|
||||
///
|
||||
bool allowsCaptionVariation(std::string const &) const;
|
||||
///
|
||||
DisplayType display() const;
|
||||
///
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
|
@ -88,8 +88,6 @@ Format LaTeX feature LyX feature
|
||||
\usepackage[scale|scaled=$val]{biolinum-type1}
|
||||
\font_sans
|
||||
\font_sf_scale
|
||||
463
|
||||
465
|
||||
466 Powerdot updates:
|
||||
\pause[] layout Pause
|
||||
\onslide{}{} InsetFlex, InsetArgument
|
||||
@ -100,6 +98,7 @@ Format LaTeX feature LyX feature
|
||||
\begin{enumerate|itemize|...}[] InsetArgument
|
||||
467 support for iwona math font (the other iwona fonts are already supported)
|
||||
|
||||
|
||||
General
|
||||
|
||||
* Use the language information provided by Language.cpp and the languages file (for babel/lyx/polyglossia name, quote style etc.)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 468
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
@ -1369,7 +1369,7 @@ clearpage}
|
||||
\begin_layout Standard
|
||||
|
||||
\begin_inset Tabular
|
||||
<lyxtabular version="3" rows="64" columns="2">
|
||||
<lyxtabular version="3" rows="66" columns="2">
|
||||
<features rotate="0" islongtable="true">
|
||||
<column alignment="none" valignment="top" special="@{*}r">
|
||||
<column alignment="none" valignment="top" special="|p{1in}@{*}">
|
||||
@ -1547,11 +1547,46 @@ Second
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row endfoot="true" caption="true">
|
||||
<cell multicolumn="1" alignment="none" valignment="top" topline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\begin_inset Caption LongTableNoNumber
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\begin_inset Argument 1
|
||||
status collapsed
|
||||
|
||||
\begin_layout Standard
|
||||
An optional table foot caption (used in the list of tables)
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
standard foot
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell multicolumn="2" alignment="none" valignment="top" topline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row endfoot="true">
|
||||
<cell alignment="none" valignment="top" topline="true" bottomline="true" usebox="none">
|
||||
<cell alignment="none" valignment="top" topline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Standard
|
||||
@ -1560,13 +1595,44 @@ This goes at the
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="none" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
|
||||
<cell alignment="none" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Standard
|
||||
bottom.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row endlastfoot="true" caption="true">
|
||||
<cell multicolumn="1" alignment="none" valignment="top" topline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\begin_inset Caption LongTableNoNumber
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\begin_inset Argument 1
|
||||
status collapsed
|
||||
|
||||
\end_inset
|
||||
|
||||
(last foot)
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell multicolumn="2" alignment="none" valignment="top" topline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
|
@ -277,10 +277,14 @@ KILLED & LINE!!!! \kill
|
||||
\textbf{First}&\textbf{Second}\\
|
||||
\hline\hline
|
||||
\endhead
|
||||
\caption*
|
||||
[An optional table foot caption (used in the list of tables)]
|
||||
{standard foot}\\
|
||||
\hline
|
||||
This goes at the&bottom.\\
|
||||
\hline
|
||||
\endfoot
|
||||
\caption*[]{(last foot)}\\
|
||||
\hline
|
||||
These lines will&appear\\
|
||||
in place of the & usual foot\\
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass amsart
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass book
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.1.0dev
|
||||
\lyxformat 467
|
||||
\lyxformat 469
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
|
@ -2792,10 +2792,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
}
|
||||
|
||||
else if (t.cs() == "caption") {
|
||||
bool starred = false;
|
||||
if (p.next_token().asInput() == "*") {
|
||||
p.get_token();
|
||||
starred = true;
|
||||
}
|
||||
p.skip_spaces();
|
||||
context.check_layout(os);
|
||||
p.skip_spaces();
|
||||
begin_inset(os, "Caption Standard\n");
|
||||
if (starred)
|
||||
begin_inset(os, "Caption LongTableNoNumber\n");
|
||||
else
|
||||
begin_inset(os, "Caption Standard\n");
|
||||
Context newcontext(true, context.textclass, 0, 0, context.font);
|
||||
newcontext.check_layout(os);
|
||||
// FIXME InsetArgument is now properly implemented in InsetLayout
|
||||
|
@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 468 // uwestoehr: mbox/fbox support
|
||||
#define LYX_FORMAT_TEX2LYX 468 // uwestoehr: mbox/fbox support
|
||||
#define LYX_FORMAT_LYX 469 // gb: \caption*{}
|
||||
#define LYX_FORMAT_TEX2LYX 469 // gb: \caption*{}
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user