I have tried to insert my Mathematica notebook into LaTeX by converting it as a PDF file and then using \includepdf[pages=1-4]{blablabla.pdf}. However, there are now two problems I faced:

  1. This code sample should be in the beginning of an Appendix chapter. But when I use the code \chapter{blablabla} and then the above command \includepdf, the code automatically starts from another page. Thus, an unwanted one page break occurs in my document and I don't know how to solve this.
  2. Although all the numbers in my documents are numbered in order, these pages inserted from PDF appears without numbers. This again breaks my usual layout in the document. So what is the proper way of numbering pages in that case?

Besides these problems, for future reference, I want to know the most reliable way of inserting a Mathematica code in LaTeX.

  • 2
  • Before asking the question, I took a glance at these questions. They indeed answer my last question but I didn't see anything that can possibly answer first two. What should I do to organize my document in the case I use \includepdf? That's what I am actually looking for.
    – sahin
    Commented May 10, 2015 at 20:27
  • I solved the problem about page numbers from a previous question here. Now, all left is to deal with the page breaking. I wonder if it is possible to make LaTeX resize the inserted PDF document so that I shrink it somehow and it fits to the first page, just under the chapter name.
    – sahin
    Commented May 10, 2015 at 20:43
  • what \includepdf does is insert the whole page(s) of the specified PDF literally into the document. This necessitates a page break before the pages are inserted. The default pagecommand (pagecommand={\thispagestyle{empty}}) causes no page numbers on the inserted pages; you can change this key if you want numbers. But I posted those links because I think those methods are really better than this method. With \includepdf, the style of the included code will not match the rest of your document, so IMO these other methods are "more reliable". Commented May 10, 2015 at 20:44
  • 1
    Have you more infos here or is the problem solved? How?
    – Mensch
    Commented Nov 19, 2015 at 5:17

1 Answer 1


It appears that you do not want to insert complete pages but rather just include the mathematica pages as images, for which you can use \includeraphics and just scale with [width=...] as for other images.

If it is code that you are wanting to include you may be better including it as text using listings or minted or some other code highlighting package.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .