How can I write "C++" in LaTeX so that the output looks nice. For example C$++$
doesn't look good: the plus signs are too big and there is too much space.
You may be wondering how to insert symbols in LaTeX. It is possible to add certain symbols in-text while others require LaTeX's math mode to be activated. ”, you can use the command \star in your code.
In LaTeX, the packages gensymb and textcomp provide the commands \degree and \textdegree , respectively. In the absence of these packages one can write the degree symbol as ^{\circ} in math mode. In other words, it is written as the empty circle glyph circ as a superscript.
If you simply want the character to be printed just as any other letter, include a \ in front of the character. For example, \$ will produce $ in your output. The exception to the rule is the \ itself because \\ has its own special meaning. A \ is produced by typing $\backslash$ in your file.
The degree Celsius (symbol: °C) can refer to a specific temperature on the Celsius scale or a unit to indicate a difference or range between two temperatures. It is named after the Swedish astronomer Anders Celsius (1701–1744), who developed a similar temperature scale in 1742.
The standard solution for cases like this is to use verbatim:
\verb!C++!
I've been using the code below to typset a nice looking C++ in my Master-Thesis. The code has been copied verbatim from a german forum. You should be able to just copy-paste all the code in a new .tex-document and pick the relevant stuff for you...
\documentclass{article} \usepackage{relsize} \usepackage{lipsum} %c from texinfo.tex \def\ifmonospace{\ifdim\fontdimen3\font=0pt } %c C plus plus \def\C++{% \ifmonospace% C++% \else% C\kern-.1667em\raise.30ex\hbox{\smaller{++}}% \fi% \spacefactor1000 } %c C sharp \def\Csharp{% \ifmonospace% C\#% \else% C\kern-.1667em\raise.30ex\hbox{\smaller{\#}}% \fi% \spacefactor1000 } \begin{document} \begin{center} {\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp}\\ \bigskip \ttfamily {\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp}\\ \bigskip \sffamily {\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp} \end{center} \section{\C++} \lipsum[1] \subsection{\Csharp} \lipsum[1] \end{document}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With