In the lyx-users list is it often asked how to suppress the default date. The
solution is simply to add
\date{}
to the preamble.
The attached patch adds a document option to do this. When the user sets this option, he still can
later overwrite this be specifying a date, because the option is only for the default date.
This is a fileformat change, the lyx2lyx part follows when this goes in. This
patch fixes
http://www.lyx.org/trac/ticket/5823
regards Uwe
Index: BufferParams.cpp
===================================================================
--- BufferParams.cpp (revision 31002)
+++ BufferParams.cpp (working copy)
@@ -363,6 +363,7 @@
columns = 1;
listings_params = string();
pagestyle = "default";
+ suppress_date = false;
// white is equal to no background color
backgroundcolor = lyx::rgbFromHexName("#ffffff");
compressed = false;
@@ -539,6 +540,8 @@
} else if (token == "\\master") {
lex.eatLine();
master = lex.getString();
+ } else if (token == "\\suppress_date") {
+ lex >> suppress_date;
} else if (token == "\\language") {
readLanguage(lex);
} else if (token == "\\inputencoding") {
@@ -863,6 +866,7 @@
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\use_indices " << convert<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation]
+ << "\n\\suppress_date " << convert<string>(suppress_date)
<< '\n';
if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
@@ -1459,6 +1463,10 @@
// Line spacing
lyxpreamble += from_utf8(spacing().writePreamble(tclass.provides("SetSpace")));
+ // date
+ if (suppress_date)
+ lyxpreamble += "\\date{}\n";
+
// PDF support.
// * Hyperref manual: "Make sure it comes last of your loaded
// packages, to give it a fighting chance of not being over-written,
Index: BufferParams.h
===================================================================
--- BufferParams.h (revision 31002)
+++ BufferParams.h (working copy)
@@ -259,6 +259,8 @@
///
std::string master;
///
+ bool suppress_date;
+ ///
std::string float_placement;
///
unsigned int columns;
Index: frontends/qt4/GuiDocument.cpp
===================================================================
--- frontends/qt4/GuiDocument.cpp (revision 31002)
+++ frontends/qt4/GuiDocument.cpp (working copy)
@@ -932,6 +932,8 @@
this, SLOT(change_adaptor()));
connect(latexModule->childDocPB, SIGNAL(clicked()),
this, SLOT(browseMaster()));
+ connect(latexModule->suppressDateCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
// postscript drivers
for (int n = 0; tex_graphics[n][0]; ++n) {
@@ -1777,6 +1779,9 @@
// preamble
preambleModule->apply(bp_);
+ // date
+ bp_.suppress_date = latexModule->suppressDateCB->isChecked();
+
// biblio
bp_.setCiteEngine(ENGINE_BASIC);
@@ -2148,6 +2153,9 @@
// preamble
preambleModule->update(bp_, id());
+ // date
+ latexModule->suppressDateCB->setChecked(bp_.suppress_date);
+
// biblio
biblioModule->citeDefaultRB->setChecked(
bp_.citeEngine() == ENGINE_BASIC);
Index: frontends/qt4/ui/LaTeXUi.ui
===================================================================
--- frontends/qt4/ui/LaTeXUi.ui (revision 31002)
+++ frontends/qt4/ui/LaTeXUi.ui (working copy)
@@ -1,57 +1,49 @@
-<ui version="4.0" >
+<ui version="4.0">
<class>LaTeXUi</class>
- <widget class="QWidget" name="LaTeXUi" >
- <property name="geometry" >
+ <widget class="QWidget" name="LaTeXUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>341</width>
- <height>301</height>
+ <height>319</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string/>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" colspan="3" >
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="3">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
<string>Document &class</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="margin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="spacing">
<number>6</number>
</property>
- <item row="0" column="0" >
- <widget class="QComboBox" name="classCO" >
- <property name="maxVisibleItems" >
+ <item row="0" column="0">
+ <widget class="QComboBox" name="classCO">
+ <property name="maxVisibleItems">
<number>20</number>
</property>
</widget>
</item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="layoutPB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="layoutPB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="toolTip" >
+ <property name="toolTip">
<string>Click to select a local document class definition file</string>
</property>
- <property name="text" >
+ <property name="text">
<string>&Local Layout...</string>
</property>
</widget>
@@ -59,57 +51,57 @@
</layout>
</widget>
</item>
- <item row="1" column="0" colspan="3" >
- <widget class="QGroupBox" name="optionsGB" >
- <property name="title" >
+ <item row="1" column="0" colspan="3">
+ <widget class="QGroupBox" name="optionsGB">
+ <property name="title">
<string>Class options</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="margin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="spacing">
<number>6</number>
</property>
- <item rowspan="2" row="0" column="1" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
+ <item row="0" column="1" rowspan="2">
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
- <widget class="QLineEdit" name="defaultOptionsLE" >
- <property name="toolTip" >
+ <widget class="QLineEdit" name="defaultOptionsLE">
+ <property name="toolTip">
<string>The options that are predefined in the layout file. Click to the left to select/deselect.</string>
</property>
- <property name="readOnly" >
+ <property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="optionsLE" />
+ <widget class="QLineEdit" name="optionsLE"/>
</item>
</layout>
</item>
- <item row="0" column="0" >
- <widget class="QCheckBox" name="defaultOptionsCB" >
- <property name="toolTip" >
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="defaultOptionsCB">
+ <property name="toolTip">
<string>Enable to use the options that are predefined in the layout file</string>
</property>
- <property name="text" >
+ <property name="text">
<string>P&redefined:</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QLabel" name="optionsL" >
- <property name="text" >
+ <item row="1" column="0">
+ <widget class="QLabel" name="optionsL">
+ <property name="text">
<string>Cust&om:</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>optionsLE</cstring>
</property>
</widget>
@@ -117,29 +109,29 @@
</layout>
</widget>
</item>
- <item row="2" column="0" >
- <widget class="QLabel" name="psdriverL" >
- <property name="text" >
+ <item row="2" column="0">
+ <widget class="QLabel" name="psdriverL">
+ <property name="text">
<string>&Graphics driver:</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>psdriverCO</cstring>
</property>
</widget>
</item>
- <item row="2" column="1" >
- <widget class="QComboBox" name="psdriverCO" >
- <property name="duplicatesEnabled" >
+ <item row="2" column="2">
+ <widget class="QComboBox" name="psdriverCO">
+ <property name="duplicatesEnabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="2" column="2" >
- <spacer>
- <property name="orientation" >
+ <item row="2" column="3">
+ <spacer name="horizontalSpacer_1">
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>261</width>
<height>22</height>
@@ -147,47 +139,47 @@
</property>
</spacer>
</item>
- <item row="3" column="0" colspan="3" >
- <widget class="QGroupBox" name="childDocGB" >
- <property name="toolTip" >
+ <item row="3" column="0" colspan="4">
+ <widget class="QGroupBox" name="childDocGB">
+ <property name="toolTip">
<string>Select if the current document is included to a master file</string>
</property>
- <property name="statusTip" >
+ <property name="statusTip">
<string/>
</property>
- <property name="title" >
+ <property name="title">
<string>Select de&fault master document</string>
</property>
- <property name="checkable" >
+ <property name="checkable">
<bool>true</bool>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="margin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="spacing">
<number>6</number>
</property>
- <item row="0" column="0" >
- <widget class="QLabel" name="childDocLA" >
- <property name="text" >
+ <item row="0" column="0">
+ <widget class="QLabel" name="childDocLA">
+ <property name="text">
<string>&Master:</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>childDocLE</cstring>
</property>
</widget>
</item>
- <item row="0" column="2" >
- <widget class="QPushButton" name="childDocPB" >
- <property name="text" >
+ <item row="0" column="2">
+ <widget class="QPushButton" name="childDocPB">
+ <property name="text">
<string>&Browse...</string>
</property>
</widget>
</item>
- <item row="0" column="1" >
- <widget class="QLineEdit" name="childDocLE" >
- <property name="toolTip" >
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="childDocLE">
+ <property name="toolTip">
<string>Enter the name of the default master document</string>
</property>
</widget>
@@ -195,12 +187,28 @@
</layout>
</widget>
</item>
- <item row="4" column="0" >
- <spacer>
- <property name="orientation" >
+ <item row="4" column="0" colspan="4">
+ <widget class="QCheckBox" name="suppressDateCB">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Suppress default date on front page</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2</height>
@@ -216,7 +224,7 @@
<tabstop>psdriverCO</tabstop>
</tabstops>
<includes>
- <include location="local" >qt_i18n.h</include>
+ <include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections>
@@ -226,11 +234,11 @@
<receiver>defaultOptionsLE</receiver>
<slot>setEnabled(bool)</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>63</x>
<y>79</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>237</x>
<y>82</y>
</hint>