+ features.useInsetLayout(getLayout());
+ for_each(paragraphs().begin(), paragraphs().end(),
+ bind(&Paragraph::validate, _1, ref(features)));
+}
+
+
+void InsetText::latex(otexstream & os, OutputParams const & runparams) const
+{
+ // This implements the standard way of handling the LaTeX
+ // output of a text inset, either a command or an
+ // environment. Standard collapsable insets should not
+ // redefine this, non-standard ones may call this.
+ InsetLayout const & il = getLayout();
+ if (!il.latexname().empty()) {
+ if (il.latextype() == InsetLayout::COMMAND) {
+ // FIXME UNICODE
+ if (runparams.moving_arg)
+ os << "\\protect";
+ os << '\\' << from_utf8(il.latexname());
+ if (!il.latexparam().empty())
+ os << from_utf8(il.latexparam());
+ os << '{';
+ } else if (il.latextype() == InsetLayout::ENVIRONMENT) {
+ if (il.isDisplay())
+ os << breakln;
+ else
+ os << safebreakln;
+ if (runparams.lastid != -1)
+ os.texrow().start(runparams.lastid,
+ runparams.lastpos);
+ os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
+ if (!il.latexparam().empty())
+ os << from_utf8(il.latexparam());
+ }
+ }
+ OutputParams rp = runparams;
+ if (il.isPassThru())
+ rp.pass_thru = true;
+ if (il.isNeedProtect())
+ rp.moving_arg = true;
+ rp.par_begin = 0;
+ rp.par_end = paragraphs().size();
+
+ // Output the contents of the inset
+ latexParagraphs(buffer(), text_, os, rp);
+ runparams.encoding = rp.encoding;
+
+ if (!il.latexname().empty()) {
+ if (il.latextype() == InsetLayout::COMMAND) {
+ os << "}";
+ } else if (il.latextype() == InsetLayout::ENVIRONMENT) {
+ // A comment environment doesn't need a % before \n\end
+ if (il.isDisplay() || runparams.inComment)
+ os << breakln;
+ else
+ os << safebreakln;
+ os << "\\end{" << from_utf8(il.latexname()) << "}\n";
+ if (!il.isDisplay())
+ os.protectSpace(true);
+ }
+ }