37

Currently, I have something like this:

\begin{minted}{csharp}
public static void Main (string[] args)
{
  Console.WriteLine ("Hello World!");
}
\end{minted}

Where the source code is copy/pasted from a source file.

Is there any way to include the full file within the minted section?

That way, when my code changes, my PDF will automatically update.

52

minted has \inputminted[<options>]{<language>}{<filename>} that might help you. According to the documentation, this command is used to read and format whole files.

Let's say you have your code inside hello.cs:

public static void Main (string[] args)
{
    Console.WriteLine ("Hello World!");
}

Then, in your LaTeX document:

\documentclass{article}

\usepackage{minted}

\begin{document}

\inputminted{csharp}{hello.cs}

\end{document}

The output is as expected:

Output

Hope it helps. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.