Index: lib/images/tabular-feature_set-align-decimal.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: lib\images\tabular-feature_set-align-decimal.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: lib/lyx2lyx/lyx_2_0.py
===================================================================
--- lib/lyx2lyx/lyx_2_0.py	(revision 34442)
+++ lib/lyx2lyx/lyx_2_0.py	(working copy)
@@ -28,6 +28,13 @@
 ####################################################################
 # Private helper functions
 
+def remove_option(document, m, option):
+    l = document.body[m].find(option)
+    if l != -1:
+        val = document.body[m][l:].split('"')[1]
+        document.body[m] = document.body[m][:l-1] + document.body[m][l+len(option + '="' + val + '"'):]
+    return l
+
 def find_end_of_inset(lines, i):
     " Find end of inset, where lines[i] is included."
     return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
@@ -1538,6 +1545,13 @@
       # no specified page size results in default
       del document.header[i]
 
+def revert_decimal_point(document):
+  i = 0
+  while True:
+    i = find_token(document.body, '<column', i)
+    if i == -1:
+        break
+    remove_option(document, i, 'decimal_point')
 
 ##
 # Conversion hub
@@ -1587,9 +1601,11 @@
            [386, []],
            [387, []],
            [388, []],
+           [389, []],
 					]
 
-revert =  [[387, [revert_pagesizes]],
+revert =  [[388, [revert_decimal_point]],
+           [387, [revert_pagesizes]],
            [386, [revert_math_scale]],
            [385, [revert_lyx_version]],
            [384, [revert_shadedboxcolor]],
Index: lib/ui/stdtoolbars.inc
===================================================================
--- lib/ui/stdtoolbars.inc	(revision 34442)
+++ lib/ui/stdtoolbars.inc	(working copy)
@@ -153,6 +153,7 @@
 		Item "Align left" "command-alternatives inset-modify tabular m-align-left;inset-modify tabular align-left"
 		Item "Align center" "command-alternatives inset-modify tabular m-align-center;inset-modify tabular align-center"
 		Item "Align right" "command-alternatives inset-modify tabular m-align-right;inset-modify tabular align-right"
+		Item "Align on decimal" "inset-modify tabular set-align-decimal"
 		Separator
 		Item "Align top" "command-alternatives inset-modify tabular m-valign-top;inset-modify tabular valign-top"
 		Item "Align middle" "command-alternatives inset-modify tabular m-valign-middle;inset-modify tabular valign-middle"
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revision 34442)
+++ src/Buffer.cpp	(working copy)
@@ -126,7 +126,7 @@
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 388; // uwestoehr: support for more page sizes
+int const LYX_FORMAT = 389; // edwin: decimal alignment in tables
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
Index: src/frontends/qt4/GuiPrefs.cpp
===================================================================
--- src/frontends/qt4/GuiPrefs.cpp	(revision 34442)
+++ src/frontends/qt4/GuiPrefs.cpp	(working copy)
@@ -2070,6 +2070,8 @@
 		this, SIGNAL(changed()));
 	connect(uiLanguageCO, SIGNAL(activated(int)),
 		this, SIGNAL(changed()));
+	connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
+		this, SIGNAL(changed()));
 
 	uiLanguageCO->clear();
 
@@ -2113,6 +2115,7 @@
 	rc.language_command_end = fromqstr(endCommandED->text());
 	rc.gui_language = fromqstr(
 		uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
+	rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
 }
 
 
@@ -2132,6 +2135,7 @@
 	languagePackageED->setText(toqstr(rc.language_package));
 	startCommandED->setText(toqstr(rc.language_command_begin));
 	endCommandED->setText(toqstr(rc.language_command_end));
+	defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
 
 	int pos = uiLanguageCO->findData(toqstr(rc.gui_language));
 	uiLanguageCO->blockSignals(true);
Index: src/frontends/qt4/GuiTabular.cpp
===================================================================
--- src/frontends/qt4/GuiTabular.cpp	(revision 34442)
+++ src/frontends/qt4/GuiTabular.cpp	(working copy)
@@ -27,6 +27,7 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LyX.h"
+#include "LyXRC.h"
 
 #include "insets/InsetTabular.h"
 
@@ -376,6 +377,12 @@
 		setParam(param_str, Tabular::UNSET_BOOKTABS);
 
 	//
+	string decimal_point = lyxrc.default_decimal_point;
+	if (decimalCB->isChecked() && !decimalPointLE->text().isEmpty())
+		decimal_point = fromqstr(decimalPointLE->text());
+	setParam(param_str, Tabular::SET_ALIGN_DECIMAL, decimal_point);
+
+	//
 	switch (topspaceCO->currentIndex()) {
 		case 0:
 			setParam(param_str, Tabular::SET_TOP_SPACE, "none");
@@ -753,6 +760,10 @@
 	}
 	TableAlignCB->setCurrentIndex(tableValign);
 
+	QString const decimal_point = toqstr(tabular.column_info[col].decimal_point);
+	decimalCB->setChecked(!decimal_point.isEmpty());
+	decimalPointLE->setText(decimal_point);
+
 	if (!tabular.is_long_tabular) {
 		headerStatusCB->setChecked(false);
 		headerBorderAboveCB->setChecked(false);
Index: src/frontends/qt4/ui/PrefLanguageUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefLanguageUi.ui	(revision 34442)
+++ src/frontends/qt4/ui/PrefLanguageUi.ui	(working copy)
@@ -43,14 +43,31 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="2" rowspan="2">
+   <item row="1" column="2">
     <widget class="QLineEdit" name="languagePackageED">
      <property name="toolTip">
       <string>Enter the command to load the language package (default: babel)</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="3" rowspan="2">
+   <item row="2" column="0" colspan="2">
+    <widget class="QLabel" name="startCommandLA">
+     <property name="text">
+      <string>Command s&amp;tart:</string>
+     </property>
+     <property name="buddy">
+      <cstring>startCommandED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2">
+    <widget class="QLineEdit" name="startCommandED">
+     <property name="toolTip">
+      <string>The LaTeX command that starts a switch to a foreign language</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="3">
     <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -64,36 +81,36 @@
     </spacer>
    </item>
    <item row="3" column="0" colspan="2">
-    <widget class="QLabel" name="startCommandLA">
+    <widget class="QLabel" name="endCommandLA">
      <property name="text">
-      <string>Command s&amp;tart:</string>
+      <string>Command e&amp;nd:</string>
      </property>
      <property name="buddy">
-      <cstring>startCommandED</cstring>
+      <cstring>endCommandED</cstring>
      </property>
     </widget>
    </item>
    <item row="3" column="2">
-    <widget class="QLineEdit" name="startCommandED">
+    <widget class="QLineEdit" name="endCommandED">
      <property name="toolTip">
-      <string>The LaTeX command that starts a switch to a foreign language</string>
+      <string>The LaTeX command that ends a switch to a foreign language</string>
      </property>
     </widget>
    </item>
    <item row="4" column="0" colspan="2">
-    <widget class="QLabel" name="endCommandLA">
+    <widget class="QLabel" name="decimalPointL">
      <property name="text">
-      <string>Command e&amp;nd:</string>
+      <string>Default Decimal &amp;Point:</string>
      </property>
      <property name="buddy">
-      <cstring>endCommandED</cstring>
+      <cstring>defaultDecimalPointLE</cstring>
      </property>
     </widget>
    </item>
    <item row="4" column="2">
-    <widget class="QLineEdit" name="endCommandED">
-     <property name="toolTip">
-      <string>The LaTeX command that ends a switch to a foreign language</string>
+    <widget class="QLineEdit" name="defaultDecimalPointLE">
+     <property name="inputMask">
+      <string>X; </string>
      </property>
     </widget>
    </item>
@@ -244,14 +261,19 @@
   </layout>
  </widget>
  <tabstops>
+  <tabstop>uiLanguageCO</tabstop>
   <tabstop>languagePackageED</tabstop>
   <tabstop>startCommandED</tabstop>
   <tabstop>endCommandED</tabstop>
+  <tabstop>defaultDecimalPointLE</tabstop>
   <tabstop>useBabelCB</tabstop>
   <tabstop>globalCB</tabstop>
   <tabstop>autoBeginCB</tabstop>
   <tabstop>autoEndCB</tabstop>
   <tabstop>markForeignCB</tabstop>
+  <tabstop>rtlGB</tabstop>
+  <tabstop>logicalCursorRB</tabstop>
+  <tabstop>visualCursorRB</tabstop>
  </tabstops>
  <includes>
   <include location="local">qt_i18n.h</include>
Index: src/frontends/qt4/ui/TabularUi.ui
===================================================================
--- src/frontends/qt4/ui/TabularUi.ui	(revision 34442)
+++ src/frontends/qt4/ui/TabularUi.ui	(working copy)
@@ -5,17 +5,20 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>374</width>
-    <height>389</height>
+    <width>358</width>
+    <height>376</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string/>
   </property>
   <property name="sizeGripEnabled" stdset="0">
-   <bool>true</bool>
+   <bool>false</bool>
   </property>
-  <layout class="QGridLayout" name="_2">
+  <layout class="QGridLayout" name="gridLayout_9">
+   <property name="margin">
+    <number>0</number>
+   </property>
    <item row="0" column="0">
     <widget class="QTabWidget" name="TabWidget">
      <property name="toolTip">
@@ -75,7 +78,7 @@
             </item>
            </widget>
           </item>
-          <item row="0" column="2" colspan="2">
+          <item row="0" column="2">
            <spacer>
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
@@ -149,7 +152,7 @@
             </item>
            </widget>
           </item>
-          <item row="2" column="2" colspan="2">
+          <item row="2" column="2">
            <spacer name="spacer">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
@@ -165,15 +168,58 @@
             </property>
            </spacer>
           </item>
-          <item row="3" column="0">
-           <widget class="QCheckBox" name="multicolumnCB">
-            <property name="toolTip">
-             <string>Merge cells of different columns</string>
-            </property>
-            <property name="text">
-             <string>&amp;Multicolumn</string>
-            </property>
-           </widget>
+          <item row="3" column="0" colspan="4">
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <item>
+             <widget class="QCheckBox" name="multicolumnCB">
+              <property name="toolTip">
+               <string>Merge cells of different columns</string>
+              </property>
+              <property name="text">
+               <string>&amp;Multicolumn</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <spacer name="horizontalSpacer">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>13</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item>
+             <widget class="QCheckBox" name="decimalCB">
+              <property name="text">
+               <string>Align on decimal:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLineEdit" name="decimalPointLE">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="text">
+               <string/>
+              </property>
+              <property name="maxLength">
+               <number>1</number>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </widget>
@@ -309,19 +355,6 @@
          </property>
         </widget>
        </item>
-       <item row="4" column="1">
-        <spacer name="verticalSpacer_3">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>4</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="Borders">
@@ -1462,5 +1495,38 @@
   <include location="local">qt_i18n.h</include>
  </includes>
  <resources/>
- <connections/>
+ <connections>
+  <connection>
+   <sender>decimalCB</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>decimalPointLE</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>133</x>
+     <y>146</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>260</x>
+     <y>147</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>decimalCB</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>decimalPointLE</receiver>
+   <slot>setFocus()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>181</x>
+     <y>153</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>262</x>
+     <y>159</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp	(revision 34442)
+++ src/insets/InsetTabular.cpp	(working copy)
@@ -174,6 +174,7 @@
 	{ Tabular::LONGTABULAR_ALIGN_LEFT, "longtabular-align-left", false },
 	{ Tabular::LONGTABULAR_ALIGN_CENTER, "longtabular-align-center", false },
 	{ Tabular::LONGTABULAR_ALIGN_RIGHT, "longtabular-align-right", false },
+	{ Tabular::SET_ALIGN_DECIMAL, "set-align-decimal", true },
 	{ Tabular::LAST_ACTION, "", false }
 };
 
@@ -502,7 +503,31 @@
 }
 
 
+InsetTableCell splitCell(InsetTableCell & head, docstring const align_d, bool & hassep)
+{
+	InsetTableCell tail = InsetTableCell(head);
+	tail.getText(0)->setMacrocontextPosition(
+		head.getText(0)->macrocontextPosition());
+	tail.setBuffer(head.buffer());
 
+	DocIterator dit = doc_iterator_begin(&head.buffer(), &head);
+	for (; dit; dit.forwardChar())
+		if (dit.inTexted() && dit.depth()==1
+			&& dit.paragraph().find(align_d, false, false, dit.pos()))
+			break;
+
+	pit_type const psize = head.paragraphs().front().size();
+	hassep = dit;
+	if (hassep)
+		head.paragraphs().front().eraseChars(dit.pos(), psize, false);
+
+	tail.paragraphs().front().eraseChars(0, 
+		dit.pos() < psize ? dit.pos() + 1 : psize, false);
+
+	return tail;
+}
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // Tabular
@@ -517,6 +542,8 @@
 	  multirow(Tabular::CELL_NORMAL),
 	  alignment(LYX_ALIGN_CENTER),
 	  valignment(LYX_VALIGN_TOP),
+	  decimal_hoffset(0),
+	  decimal_width(0),
 	  voffset(0),
 	  top_line(false),
 	  bottom_line(false),
@@ -537,6 +564,8 @@
 	  multirow(cs.multirow),
 	  alignment(cs.alignment),
 	  valignment(cs.valignment),
+	  decimal_hoffset(cs.decimal_hoffset),
+	  decimal_width(cs.decimal_width),
 	  voffset(cs.voffset),
 	  top_line(cs.top_line),
 	  bottom_line(cs.bottom_line),
@@ -564,6 +593,8 @@
 	std::swap(multirow, rhs.multirow);
 	std::swap(alignment, rhs.alignment);
 	std::swap(valignment, rhs.valignment);
+	std::swap(decimal_hoffset, rhs.decimal_hoffset);
+	std::swap(decimal_width, rhs.decimal_width);
 	std::swap(voffset, rhs.voffset);
 	std::swap(top_line, rhs.top_line);
 	std::swap(bottom_line, rhs.bottom_line);
@@ -651,6 +682,14 @@
 }
 
 
+bool Tabular::alignDecimal(idx_type cell) const
+{
+	return !isMultiColumn(cell) && !isMultiRow(cell)
+		&& !column_info[cellColumn(cell)].decimal_point.empty() 
+		&& cellInfo(cell).decimal_width!=0;
+}
+
+
 void Tabular::appendRow(idx_type const cell)
 {
 	row_type const row = cellRow(cell);
@@ -910,6 +949,11 @@
 
 bool Tabular::updateColumnWidths()
 {
+	vector<int> max_dwidth(ncols(), 0);
+	for(col_type c = 0; c < ncols(); ++c)
+		for(row_type r = 0; r < nrows(); ++r)
+			max_dwidth[c] = max(max_dwidth[c], cell_info[r][c].decimal_width);
+
 	bool update = false;
 	// for each col get max of single col cells
 	for(col_type c = 0; c < ncols(); ++c) {
@@ -917,7 +961,8 @@
 		for(row_type r = 0; r < nrows(); ++r) {
 			idx_type const i = cellIndex(r, c);
 			if (columnSpan(i) == 1)
-				new_width = max(new_width, cellInfo(i).width);
+				new_width = max(new_width, cellInfo(i).width 
+				                + max_dwidth[c] - cellInfo(i).decimal_width);
 		}
 
 		if (column_info[c].width != new_width) {
@@ -1217,6 +1262,17 @@
 		break;
 	}
 
+	if (alignDecimal(cell)) {
+		col_type const c = cellColumn(cell);
+		int max_dhoffset = 0;
+		for(row_type r = 0; r < row_info.size() ; ++r) {
+			idx_type const i = cellIndex(r, c);
+			if (alignDecimal(i))
+				max_dhoffset = max(max_dhoffset, cellInfo(i).decimal_hoffset);
+		}
+		x = WIDTH_OF_LINE + max_dhoffset - cellInfo(cell).decimal_hoffset;
+	}
+
 	return x;
 }
 
@@ -1307,6 +1363,7 @@
 		   << write_attribute("valignment", column_info[c].valignment)
 		   << write_attribute("width", column_info[c].p_width.asString())
 		   << write_attribute("special", column_info[c].align_special)
+		   << write_attribute("decimal_point", column_info[c].decimal_point)
 		   << ">\n";
 	}
 	for (row_type r = 0; r < nrows(); ++r) {
@@ -1413,6 +1470,7 @@
 		getTokenValue(line, "valignment", column_info[c].valignment);
 		getTokenValue(line, "width", column_info[c].p_width);
 		getTokenValue(line, "special", column_info[c].align_special);
+		getTokenValue(line, "decimal_point", column_info[c].decimal_point);
 	}
 
 	for (row_type i = 0; i < nrows(); ++i) {
@@ -1563,11 +1621,12 @@
 Tabular::idx_type Tabular::columnSpan(idx_type cell) const
 {
 	row_type const row = cellRow(cell);
-	col_type column = cellColumn(cell) + 1;
-	while (column < ncols() && isPartOfMultiColumn(row, column))
-		++column;
+	col_type const col = cellColumn(cell);
+	int span = 1;
+	while (col + span < ncols() && isPartOfMultiColumn(row, col + span))
+		++span;
 
-	return column - cellColumn(cell);
+	return span;
 }
 
 
@@ -1935,21 +1994,27 @@
 			os << "\\hline ";
 		}
 	} else if (row == 0) {
+		col_type offset = 0;
 		for (col_type c = 0; c < ncols(); ++c) {
-			if (topline[c]) {
-				//babel makes the "-" character an active one, so we have to suppress this here
-				//see http://groups.google.com/group/comp.text.tex/browse_thread/thread/af769424a4a0f289#
-				if (lang == "slovak" || lang == "czech")
-					os << (use_booktabs ? "\\expandafter\\cmidrule\\expandafter{\\expandafter" :
-					                      "\\expandafter\\cline\\expandafter{\\expandafter")
-										  << c + 1 << "\\string-";
-				else
-					os << (use_booktabs ? "\\cmidrule{" : "\\cline{") << c + 1 << '-';
-				// get to last column of line span
-				while (c < ncols() && topline[c])
-					++c;
-				os << c << "} ";
-			}
+			// move forward until lines start
+			for ( ; c < ncols() && !topline[c]; ++c)
+				if (!column_info[c].decimal_point.empty())
+					++offset;
+
+			//babel makes the "-" character an active one, so we have to suppress this here
+			//see http://groups.google.com/group/comp.text.tex/browse_thread/thread/af769424a4a0f289#
+			if (lang == "slovak" || lang == "czech")
+				os << "\\expandafter" << (use_booktabs ? "\\cmidrule" : "\\cline") 
+				   << "\\expandafter{\\expandafter" << c + 1 + offset << "\\string-";
+			else
+				os << (use_booktabs ? "\\cmidrule{" : "\\cline{") << c + 1 + offset << '-';
+
+			// move forward until lines end
+			for ( ; c < ncols() && topline[c]; ++c)
+				if (!column_info[c].decimal_point.empty())
+					++offset;
+
+			os << c + offset << "} ";
 		}
 	}
 	os << "\n";
@@ -1999,21 +2064,27 @@
 		else
 			os << "\\hline ";
 	} else {
+		col_type offset = 0;
 		for (col_type c = 0; c < ncols(); ++c) {
-			if (bottomline[c]) {
-				//babel makes the "-" character an active one, so we have to suppress this here
-				//see http://groups.google.com/group/comp.text.tex/browse_thread/thread/af769424a4a0f289#
-				if (lang == "slovak" || lang == "czech")
-					os << (use_booktabs ? "\\expandafter\\cmidrule\\expandafter{\\expandafter" :
-					                      "\\expandafter\\cline\\expandafter{\\expandafter")
-										  << c + 1 << "\\string-";
-				else
-					os << (use_booktabs ? "\\cmidrule{" : "\\cline{") << c + 1 << '-';
-				// get to last column of line span
-				while (c < ncols() && bottomline[c])
-					++c;
-				os << c << "} ";
-			}
+			// move forward until lines start
+			for ( ; c < ncols() && !bottomline[c]; ++c)
+				if (!column_info[c].decimal_point.empty())
+					++offset;
+
+			//babel makes the "-" character an active one, so we have to suppress this here
+			//see http://groups.google.com/group/comp.text.tex/browse_thread/thread/af769424a4a0f289#
+			if (lang == "slovak" || lang == "czech")
+				os << "\\expandafter" << (use_booktabs ? "\\cmidrule" : "\\cline") 
+				   << "\\expandafter{\\expandafter" << c + 1 + offset << "\\string-";
+			else
+				os << (use_booktabs ? "\\cmidrule{" : "\\cline{") << c + 1 + offset << '-';
+
+			// move forward until lines end
+			for ( ; c < ncols() && bottomline[c]; ++c)
+				if (!column_info[c].decimal_point.empty())
+					++offset;
+
+			os << c + offset << "} ";
 		}
 	}
 	os << "\n";
@@ -2048,8 +2119,18 @@
 		|| ((colright || nextcolleft) && !rightLine(cell) && !nextcellleft)
 		|| (!colright && !nextcolleft && (rightLine(cell) || nextcellleft))
 		|| (coldouble != celldouble);
+
+	ismulticol |= !column_info[c].decimal_point.empty() 
+		&& !alignDecimal(cell);
+
+	// since decimally aligned cols = 2 latex cols
+	int latexcolspan = columnSpan(cell);
+	for(col_type col = c; col < c + columnSpan(cell); ++col)
+		if (!column_info[col].decimal_point.empty())
+			++latexcolspan;
+
 	if (ismulticol) {
-		os << "\\multicolumn{" << columnSpan(cell) << "}{";
+		os << "\\multicolumn{" << latexcolspan << "}{";
 		if (c ==0 && leftLine(cell))
 			os << '|';
 		if (!cellInfo(cell).align_special.empty()) {
@@ -2177,9 +2258,11 @@
 		os << "%\n\\end{sideways}";
 		++ret;
 	}
-	if (ismulticol || ismultirow) {
+	if (ismultirow)
 		os << '}';
-	}
+	if (ismulticol)
+		os << '}';
+
 	return ret;
 }
 
@@ -2360,7 +2443,21 @@
 		newrp.inTableCell = (getAlignment(cell) == LYX_ALIGN_BLOCK)
 				    ? OutputParams::PLAIN
 				    : OutputParams::ALIGNED;
-		ret += inset->latex(os, newrp);
+
+		if (alignDecimal(cell)) {
+			// copy cell and split in 2
+			InsetTableCell head = InsetTableCell(*cellInset(cell).get());
+			head.getText(0)->setMacrocontextPosition(
+				cellInset(cell)->getText(0)->macrocontextPosition());
+			head.setBuffer(buffer());
+			bool hassep = false;
+			InsetTableCell tail = splitCell(head, column_info[c].decimal_point, hassep);
+			head.latex(os, newrp);
+			os << '&';
+			ret += tail.latex(os, newrp);
+		} else 
+			ret += inset->latex(os, newrp);
+
 		runparams.encoding = newrp.encoding;
 		if (rtl)
 			os << '}';
@@ -2461,6 +2558,9 @@
 			os << '|';
 		if (!column_info[c].align_special.empty()) {
 			os << column_info[c].align_special;
+		} else if (!column_info[c].decimal_point.empty()) {
+			os << "r@{\\extracolsep{0pt}" 
+			   << column_info[c].decimal_point << "}l";
 		} else {
 			if (!column_info[c].p_width.zero()) {
 				switch (column_info[c].alignment) {
@@ -3235,6 +3335,32 @@
 			// FIXME(?): do we need a second metrics call?
 			TextMetrics const & tm = 
 				mi.base.bv->textMetrics(tabular.cellInset(cell)->getText(0));
+
+			// determine horiz offset because of decimal align (if necessary)
+			int decimal_hoffset = 0;
+			int decimal_width = 0;
+			if (!tabular.column_info[c].decimal_point.empty()
+				&& !tabular.isMultiColumn(cell)) {
+				// make a copy which we will split in 2
+				InsetTableCell head = InsetTableCell(*tabular.cellInset(cell).get());
+				head.getText(0)->setMacrocontextPosition(
+					tabular.cellInset(cell)->getText(0)->macrocontextPosition());
+				head.setBuffer(tabular.buffer());
+				// split in 2 and calculate width of each part
+				bool hassep = false;
+				InsetTableCell tail = 
+					splitCell(head, tabular.column_info[c].decimal_point, hassep);
+				Dimension dim1;
+				head.metrics(m, dim1);
+				decimal_hoffset = dim1.width();
+				if (hassep) {
+					tail.metrics(m, dim1);
+					decimal_width = dim1.width();
+				}
+			}
+			tabular.cell_info[r][c].decimal_hoffset = decimal_hoffset;
+			tabular.cell_info[r][c].decimal_width = decimal_width;
+
 			// with LYX_VALIGN_BOTTOM the descent is relative to the last par
 			// = descent of text in last par + TEXT_TO_INSET_OFFSET:
 			int const lastpardes = tm.last().second->descent()
@@ -4040,6 +4166,11 @@
 			status.clear();
 			return true;
 
+		case Tabular::SET_ALIGN_DECIMAL: {
+			Tabular::col_type col = tabular.cellColumn(cur.idx());
+			status.setOnOff(!tabular.column_info[col].decimal_point.empty());
+		}
+
 		case Tabular::MULTICOLUMN:
 			// If a row is set as longtable caption, it must not be allowed
 			// to unset that this row is a multicolumn.
@@ -5245,6 +5376,17 @@
 		break;
 	}
 
+	case Tabular::SET_ALIGN_DECIMAL: {
+		for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
+			string ds = value;
+			// without argument we toggle
+			if (ds=="" && tabular.column_info[c].decimal_point.empty())
+				ds = lyxrc.default_decimal_point;
+			tabular.column_info[c].decimal_point = from_ascii(ds);
+		}
+		break;
+	}
+
 	// dummy stuff just to avoid warnings
 	case Tabular::LAST_ACTION:
 		break;
Index: src/insets/InsetTabular.h
===================================================================
--- src/insets/InsetTabular.h	(revision 34442)
+++ src/insets/InsetTabular.h	(working copy)
@@ -190,6 +190,8 @@
 		///
 		LONGTABULAR_ALIGN_RIGHT,
 		///
+		SET_ALIGN_DECIMAL,
+		///
 		LAST_ACTION
 	};
 	///
@@ -337,6 +339,8 @@
 	VAlignment getVAlignment(idx_type cell,
 				 bool onlycolumn = false) const;
 	///
+	bool alignDecimal(idx_type cell) const;
+	///
 	Length const getPWidth(idx_type cell) const;
 	///
 	int cellWidth(idx_type cell) const;
@@ -490,6 +494,10 @@
 		LyXAlignment alignment;
 		///
 		VAlignment valignment;
+		/// width of the part before the decimal
+		int decimal_hoffset;
+		/// width of the decimal part
+		int decimal_width;
 		///
 		int voffset;
 		///
@@ -570,6 +578,8 @@
 		Length p_width;
 		///
 		docstring align_special;
+		///
+		docstring decimal_point;
 	};
 	///
 	typedef std::vector<ColumnData> column_vector;
@@ -944,6 +954,9 @@
 
 std::string const featureAsString(Tabular::Feature feature);
 
+/// Split cell on decimal symbol
+InsetTableCell splitCell(InsetTableCell & head, docstring const decimal_sym, bool & hassep);
+
 } // namespace lyx
 
 #endif // INSET_TABULAR_H
Index: src/LyXRC.cpp
===================================================================
--- src/LyXRC.cpp	(revision 34442)
+++ src/LyXRC.cpp	(working copy)
@@ -84,6 +84,7 @@
 	{ "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
 	{ "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
 	{ "\\def_file", LyXRC::RC_DEFFILE },
+	{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
 	{ "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
 	{ "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
 	{ "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
@@ -352,6 +353,7 @@
 	completion_inline_text = false;
 	completion_inline_dots = -1;
 	completion_inline_delay = 0.2;
+	default_decimal_point = ".";
 }
 
 
@@ -939,6 +941,9 @@
 				backupdir_path = expandPath(backupdir_path);
 			}
 			break;
+		case RC_DEFAULT_DECIMAL_POINT:
+			lexrc >> default_decimal_point;
+			break;
 		case RC_DATE_INSERT_FORMAT:
 			lexrc >> date_insert_format;
 			break;
@@ -2365,6 +2370,14 @@
 		if (tag != RC_LAST)
 			break;
 
+	case RC_DEFAULT_DECIMAL_POINT:
+		if (ignore_system_lyxrc ||
+		    default_decimal_point != system_lyxrc.default_decimal_point) {
+			os << "\\default_decimal_point " << default_decimal_point << '\n';
+		}
+		if (tag != RC_LAST)
+			break;
+
 	case RC_SPELLCHECKER:
 		if (ignore_system_lyxrc ||
 		    spellchecker != system_lyxrc.spellchecker) {
Index: src/LyXRC.h
===================================================================
--- src/LyXRC.h	(revision 34442)
+++ src/LyXRC.h	(working copy)
@@ -66,6 +66,7 @@
 		RC_COPIER,
 		RC_CURSOR_FOLLOWS_SCROLLBAR,
 		RC_DATE_INSERT_FORMAT,
+		RC_DEFAULT_DECIMAL_POINT,
 		RC_DEFAULT_LANGUAGE,
 		RC_DEFAULT_VIEW_FORMAT,
 		RC_DEFAULT_PAPERSIZE,
@@ -499,6 +500,8 @@
 	std::string forward_search_pdf;
 	///
 	int export_overwrite;
+	/// Default decimal point when aligning table columns on decimal
+	std::string default_decimal_point;
 };
 
 
