diff --git a/IPython/nbconvert/templates/html_basic.tpl b/IPython/nbconvert/templates/html_basic.tpl
index fd97f03..543beee 100644
--- a/IPython/nbconvert/templates/html_basic.tpl
+++ b/IPython/nbconvert/templates/html_basic.tpl
@@ -65,10 +65,6 @@ In [{{ cell.prompt_number }}]:
{% endblock headingcell %}
-{% block rawcell scoped %}
-{{ cell.source }}
-{% endblock rawcell %}
-
{% block unknowncell scoped %}
unknown type {{ cell.type }}
{% endblock unknowncell %}
diff --git a/IPython/nbconvert/templates/latex/latex_base.tplx b/IPython/nbconvert/templates/latex/latex_base.tplx
index 0ad51fa..97a67a5 100644
--- a/IPython/nbconvert/templates/latex/latex_base.tplx
+++ b/IPython/nbconvert/templates/latex/latex_base.tplx
@@ -218,11 +218,6 @@ This template does not define a docclass, the inheriting class must define this.
((( cell.source | citation2latex | markdown2latex )))
((* endblock markdowncell *))
-% Spit out the contents of raw cells unmodified
-((* block rawcell scoped *))
- ((( cell.source )))
-((* endblock rawcell *))
-
% Don't display unknown types
((* block unknowncell scoped *))
((* endblock unknowncell *))
diff --git a/IPython/nbconvert/templates/latex/skeleton/null.tplx b/IPython/nbconvert/templates/latex/skeleton/null.tplx
index 33bc591..7fa6b48 100644
--- a/IPython/nbconvert/templates/latex/skeleton/null.tplx
+++ b/IPython/nbconvert/templates/latex/skeleton/null.tplx
@@ -80,7 +80,10 @@ consider calling super even if it is a leave block, we might insert more blocks
((*- block headingcell scoped-*))
((*- endblock headingcell -*))
((*- elif cell.cell_type in ['raw'] -*))
- ((*- block rawcell scoped-*))
+ ((*- block rawcell scoped -*))
+ ((* if cell.metadata.get('raw_format', resources.get('raw_format')) == resources.get('raw_format') *))
+ ((( cell.source )))
+ ((* endif *))
((*- endblock rawcell -*))
((*- else -*))
((*- block unknowncell scoped-*))
diff --git a/IPython/nbconvert/templates/markdown.tpl b/IPython/nbconvert/templates/markdown.tpl
index 399c012..0946268 100644
--- a/IPython/nbconvert/templates/markdown.tpl
+++ b/IPython/nbconvert/templates/markdown.tpl
@@ -63,10 +63,6 @@
{{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
{% endblock headingcell %}
-{% block rawcell scoped %}
-{{ cell.source }}
-{% endblock rawcell %}
-
{% block unknowncell scoped %}
unknown type {{ cell.type }}
{% endblock unknowncell %}
\ No newline at end of file
diff --git a/IPython/nbconvert/templates/python.tpl b/IPython/nbconvert/templates/python.tpl
index f619206..c863da7 100644
--- a/IPython/nbconvert/templates/python.tpl
+++ b/IPython/nbconvert/templates/python.tpl
@@ -46,10 +46,6 @@ it introduces a new line
{{ '#' * cell.level }}{{ cell.source | replace('\n', ' ') | comment_lines }}
{% endblock headingcell %}
-{% block rawcell scoped %}
-{{ cell.source | comment_lines }}
-{% endblock rawcell %}
-
{% block unknowncell scoped %}
unknown type {{ cell.type }}
{% endblock unknowncell %}
\ No newline at end of file
diff --git a/IPython/nbconvert/templates/rst.tpl b/IPython/nbconvert/templates/rst.tpl
index d0a7fc2..7f25aca 100644
--- a/IPython/nbconvert/templates/rst.tpl
+++ b/IPython/nbconvert/templates/rst.tpl
@@ -75,10 +75,6 @@
{{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }}
{% endblock headingcell %}
-{% block rawcell scoped %}
-{{ cell.source }}
-{% endblock rawcell %}
-
{% block unknowncell scoped %}
unknown type {{cell.type}}
{% endblock unknowncell %}
diff --git a/IPython/nbconvert/templates/skeleton/null.tpl b/IPython/nbconvert/templates/skeleton/null.tpl
index 24066f2..2d40ed3 100644
--- a/IPython/nbconvert/templates/skeleton/null.tpl
+++ b/IPython/nbconvert/templates/skeleton/null.tpl
@@ -76,7 +76,10 @@ consider calling super even if it is a leave block, we might insert more blocks
{%- block headingcell scoped-%}
{%- endblock headingcell -%}
{%- elif cell.cell_type in ['raw'] -%}
- {%- block rawcell scoped-%}
+ {%- block rawcell scoped -%}
+ {% if cell.metadata.get('raw_format', resources.get('raw_format', '')).lower() in resources.get('raw_formats', ['']) %}
+ {{ cell.source }}
+ {% endif %}
{%- endblock rawcell -%}
{%- else -%}
{%- block unknowncell scoped-%}