Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm re-discovering LaTeX after an absence of 15-17 years. Sadly all my previous skills are gone so I'm starting from scratch.

I am taking two grad courses for which I have to submit assignments every week which involve embedding mathematical equations and code.

So I thought I'd post a question asking for stuff (code fragments, tools, techniques, ...) I should consider for the stated purpose.

Some things I'm currently researching:

  1. What is the best way to embed code (java, R, ...) into my Latex documents?
  2. What document type is best suited for these types of homeworks?
  3. I typically highlight my answers using a highlighter style or using boxes ... any tips on doing this in LaTeX?
  4. I typically have a header in greyed out text on every page which have the homework name, date, my name and my id printed on it ... any tips on doing this?
  5. I've discovered TexWorks and I love it ... anything else I should consider?

I read some of the previous posts here, here and here but didn't get the answers I was looking for.

share|improve this question

closed as not a real question by doncherry, percusse, Qrrbrbirlbel, zeroth, Tom Bombadil Oct 8 '12 at 19:57

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to! Please only ask one distinct question per post! This is necessary for the Q&A format here. This way, other users with similar problems can find the specific problem they're looking for. A question here revolves around one abstract issue (e.g. greying out), not so much its real-life application (e.g. your homework). Please eliminate all but one of your questions from this question. You're most welcome to ask the other questions as separate posts (after checking that such questions don't already exist on –  doncherry Oct 8 '12 at 17:43
Hi @doncherry, I read your comment and my thinking was that I'd like to find out how people best use LaTex for typesetting their homeworks. And, I feel that there are other folks out there who would have this particular questions. The points (or sub-qeustions) are points that I figure most people using LaTeX for this purpose will find useful. To –  user1172468 Oct 8 '12 at 18:01
Your questions are definitely useful, and other people may have similar questions. The problem is with the way knowledge management works here. Take for example your fifth question about editors: Assuming it hadn't been asked before, and we get lots of great answers about editors here, each of them also containing responses to your questions 1-4. Then, one day, someone comes along asking a bundled question like yours -- not about homework, but about theses instead; this question has a subquestion about editors, and others about title pages and appendices. [tbc] –  doncherry Oct 8 '12 at 18:17
[ctd] Would that question be a duplicate of yours? It certainly wouldn't make sense to have the information about editors spread out in two different questions, even though they information in the answers is going to be exactly the same. Also, homework requirements in LaTeX may not be as uniform as you think they are. I, for one, as a philologist, have never put any source code in any piece of LaTeXed homework; instead, it would be quite natural for me to include a question about numbering of linguistic examples -- which would probably seem quite odd to you. [tbc] –  doncherry Oct 8 '12 at 18:18
Hi @doncherry, tied up at the moment, will try to edit the question in a bit. Thanks. –  user1172468 Oct 8 '12 at 19:38

3 Answers 3

Some ideas:

  1. The listings package provides the lstlisting code typesetting environment and defines a number of languages, including Java and R. This is as easy as \lstset{language=java}, after which the keyword formatting will automatically be set. Of course, you can modify or improve on this. You can even include external code files using \lstinputlistings[<options>]{<file>}. See the listings documentation for more information.

  2. The standard document classes have been sufficient for most of my needs. Especially if you're talking about small/short documents, the article document class should work. book and report provides chapters, which you most likely do not need in this instance.

  3. This depends on the style of the answers. Are you only presenting a number as an answer? A whole equation? A whole paragraph? You could create an environment that prints Answer: followed by the answer.

  4. King of headers is fancyhdr. Setting the header is associated with a page style, which is easily created using

      \fancyhf{}% Clear all headers/footers
      \fancyhead{<header>}% Header
      \fancyfoot{<footer>}% Footer

    Read the fancyhdr documentation for more ideas. You may also require the xcolor package to change the font colour.

  5. For a taste of the LaTeX editors out there, see LaTeX Editors/IDEs.

share|improve this answer
I would think that also applies to questions that clash with our Q&A format by containing more than one distinct question? –  doncherry Oct 8 '12 at 17:45
  1. You could use the listings or minted packages.

  2. You can use article (or scrartcl, or memoir).

  3. You could use the framed, mdframed ot tcolorbox packages; boxes cretaed using the first two admit page breaks.

  4. You can use the fancyhdr or the titleps packages.

share|improve this answer
I would think that also applies to questions that clash with our Q&A format by containing more than one distinct question? –  doncherry Oct 8 '12 at 17:45

Just answering two out of 5 questions:

1- Check out listings package.

3- check out fancybox (texdoc fancybox).

share|improve this answer

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