<?xml version="1.0" encoding="ISO-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:axle="http://www.cs.odu.edu/~zeil/axle" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns0="http://www.cs.odu.edu/~zeil/axle" mode="ignore" id="basicUnix" ns0:xlinkuri="open/latextest.dbk" ns0:xpath="//*[@id='basicUnix']" ns0:page="latextest" foo="0 " ns0:last="/cocoon/~cs252/open/latextest/cpp.html"><head><title>Mathematics &amp; C++ Sourcecode Islands</title><link type="text/css" href="_axle/docbookstyle.css" rel="stylesheet"/><link type="text/css" href="_axle/cppformat.css" rel="stylesheet"/><link type="text/css" href="_axle/overrides.css" rel="stylesheet"/><script src="_axle/docbook.js"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/section-1.1.html" title="Prev" rel="prev"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html" title="Up" rel="up"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html" title="First" rel="first"/><script>function gotoNext() {}
function gotoPrev() {top.location.href="/cocoon/~cs252/open/latextest/section-1.1.html";}
function gotoUp() {top.location.href="/cocoon/~cs252/open/latextest/latextest.html";}
</script><xhtml:link xmlns:xhtml="http://www.w3.org/1999/xhtml" rel="stylesheet" href="_axle/navigation.css" type="text/css"/><xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/navigation.js"/></head><body><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="First" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html"><img class="navigationBar" src="_axle/first.gif" alt="First"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Prev" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/section-1.1.html"><img class="navigationBar" src="_axle/prev.gif" alt="Prev"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Up" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html"><img class="navigationBar" src="_axle/up.gif" alt="Up"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/latextest/cpp.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table><br/><script type="text/javascript">
checkForAnchorOnOtherPage('latex','latextest');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('section-1.1','section-1.1');
</script><div class="sect1" id="cpp" ns0:xpath="//*[@id='cpp']" ns0:page="cpp" ns0:prev="/cocoon/~cs252/open/latextest/section-1.1.html" ns0:up="/cocoon/~cs252/open/latextest/latextest.html" ns0:first="/cocoon/~cs252/open/latextest/latextest.html"><div class="info_sect1"><div class="title_sect2">2. C++ Markup</div></div>
  

<p class="para">A similar range of markup options exist for C++ code.

<table border="1">
<tr>
  <th width="40%">Discussion</th>
  <th width="30%">XML/HTML</th>
  <th width="30%">Rendered</th>
</tr>

<tr><td>
Put code into special elements (won't work with pages
passed through HTML Tidy)
</td><td><span class="code">
&lt;cppcode&gt;if (s == "abc") {&lt;/cppcode&gt; 
</span></td><td>
<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="code"><xhtml:span class="cppkeyword">if</xhtml:span> <xhtml:span class="cppop">(</xhtml:span><xhtml:span class="cppid">s</xhtml:span> <xhtml:span class="cppop">==</xhtml:span> <xhtml:span class="cppliteral">"abc"</xhtml:span><xhtml:span class="cppop">)</xhtml:span> <xhtml:span class="cppop">{</xhtml:span></xhtml:div> 
</td></tr>

<tr><td>
Put code into axle:cppcode attributes
</td><td><div class="screen">
&lt;span 
 axle:cppcode="#include &amp;lt;string&amp;gt;"/&gt;
</div></td><td>
<span class="code" axle:cppcode="#include &lt;string&gt;"><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cpppreproc">#include &lt;string&gt;</xhtml:span></span>
</td></tr>

<tr><td>
Or use an axle:cppcode="1" attribute to signal that an ordinary element's content should be treated as code.  (Note the use of <span class="code">&lt;![CDATA[ ... ]]&gt;</span> to tell the browser that the text inside will use &lt;, &gt;, and &amp; as ordinary characters instead of as the special HTML/XML markup.)
</td><td><div class="screen">
&lt;div axle:cppcode="1"&gt;&lt;![CDATA[
#include &lt;string&gt;

if (s != "abc") { // comment
   foo(s);
]]&gt;&lt;/div&gt;
</div></td><td>
<span class="code" axle:cppcode="1"><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cpppreproc">#include &lt;string&gt;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppkeyword">if</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">(</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppid">s</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">!=</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppliteral">"abc"</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">)</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">{</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppcomment">// comment</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/>   <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppid">foo</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">(</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppid">s</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">)</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/></span>
</td></tr>


<tr><td colspan="3">The C++ code allows a limited set of special markup features.</td></tr>

<tr><td>
Use <span class="code">&lt;[:]&gt;</span> for vertical ellipses and
<span class="code">&lt;[+]&gt;</span>...<span class="code">&lt;[-]&gt;</span> for highlighting.
</td><td><div class="screen">
&lt;div axle:cppcode="1"&gt;&lt;![CDATA[
#include &amp;lt;string&amp;gt;
   &lt;[:]&gt;
if (s != "abc") { // comment
   &lt;[+]&gt;foo(s)&lt;[-]&gt;;
]]&gt;&lt;/div&gt;
</div></td><td>
<span class="code" axle:cppcode="1"><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cpppreproc">#include &lt;string&gt;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/>   <img xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/vdots.gif"/><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppkeyword">if</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">(</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppid">s</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">!=</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppliteral">"abc"</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">)</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">{</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppcomment">// comment</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/>   <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="highlight1"><xhtml:span class="cppid">foo</xhtml:span><xhtml:span class="cppop">(</xhtml:span><xhtml:span class="cppid">s</xhtml:span><xhtml:span class="cppop">)</xhtml:span></xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/></span>
</td></tr>

<tr><td>
<span class="code">&lt;[+]&gt;</span> and <span class="code">&lt;[-]&gt;</span> 
are actually aliases for 
<span class="code">&lt;[+1]&gt;</span> and <span class="code">&lt;[-1]&gt;</span>. Alternate colors can be used as well.
</td><td><div class="screen">
&lt;div axle:cppcode="1"&gt;&lt;![CDATA[
#include &amp;lt;string&amp;gt;
   &lt;[:]&gt;
if (s &lt;[+3]&gt;!=&lt;[-3]&gt; &lt;[+2]&gt;"abc"&lt;[-2]&gt;) { // comment
   &lt;[+1]&gt;foo(s)&lt;[-1]&gt;;
]]&gt;&lt;/div&gt;
</div></td><td>
<span class="code" axle:cppcode="1"><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cpppreproc">#include &lt;string&gt;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/>   <img xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/vdots.gif"/><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppkeyword">if</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">(</xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppid">s</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="highlight3"><xhtml:span class="cppop">!=</xhtml:span></xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="highlight2"><xhtml:span class="cppliteral">"abc"</xhtml:span></xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">)</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">{</xhtml:span> <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppcomment">// comment</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/>   <xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="highlight1"><xhtml:span class="cppid">foo</xhtml:span><xhtml:span class="cppop">(</xhtml:span><xhtml:span class="cppid">s</xhtml:span><xhtml:span class="cppop">)</xhtml:span></xhtml:span><xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" class="cppop">;</xhtml:span><span class="br"/>
<xhtml:span xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:parsetree="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" axle:forumAnchor="1"/></span>
</td></tr>


</table>
</p>
</div><br/><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="First" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html"><img class="navigationBar" src="_axle/first.gif" alt="First"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Prev" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/section-1.1.html"><img class="navigationBar" src="_axle/prev.gif" alt="Prev"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Up" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/latextest/latextest.html"><img class="navigationBar" src="_axle/up.gif" alt="Up"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/latextest/cpp.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table></body></html>