General ⇒ c++ source code
c++ source code
Thanks for any advice.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
c++ source code
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 10
- Joined: Sun Jan 14, 2007 6:48 pm
Re: c++ source code
\begin{verbatim}
C++ Code to go HERE
/* the first C++ program
* - just outputs `Hello, World!'
*/
#include <iostream> // declarations for I/O
int main() // main function main()
{
/* print `Hello, World!' on standard output channel std::cout
* followed by an endline (std::endl)
*/
std::cout << "Hello, World!" << std::endl;
}
\end{verbatim}
It should do the job.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
c++ source code
olivares14031 wrote: You can use verbatim environment […] It should do the job.
What about the often demanded syntax highlighting and other formatting matters?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 27
- Joined: Wed Jan 17, 2007 12:35 pm
c++ source code
localghost wrote:olivares14031 wrote: You can use verbatim environment […] It should do the job.
What about the often demanded syntax highlighting and other formatting matters?
One possible workaround for preserving syntax highlightninh is to open source file with Scite text editor (http://scintilla.sourceforge.net/SciTE.html) and to export it as LaTeX file. It produces a really nice .tex file with all the "usual" formating.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
c++ source code
rockstar1707 wrote: One possible workaround for preserving syntax highlightninh is to open source file with Scite text editor (http://scintilla.sourceforge.net/SciTE.html) and to export it as LaTeX file. It produces a really nice .tex file with all the "usual" formating.
A workaround is completely unnecessary. The listings package is the best way to include source code into LaTeX documents. It offers settings for nearly every programming language.
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 9
- Joined: Mon Jul 09, 2007 1:46 pm