5

I am not the most experienced latex user, so I hope I can describe the problem accurately. When I compile my tex document I get following message:

! I can't write on file `test.pdf'. Please type another file name for output

! Emergency stop.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox
\fi \fi
l.1 \begin{titlepage}

I run Windows 7 if it helps and I use following packages.

\documentclass[a4paper,10pt]{report}
\usepackage{hyperref}
\usepackage{amsthm}
\usepackage{cleveref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{pdfpages}
\usepackage{appendix}
\usepackage{import}
  • 4
    Do you have the PDF open in Adobe Acrobat or another PDF reader? – darthbith Apr 10 '14 at 11:07
  • 1
    Welcome to TeX.SX! Do you have your PDF file opened in Adobe Reader, perhaps, when you try to compile? – karlkoeller Apr 10 '14 at 11:07
  • 2
    Note that not all readers lock the .pdf. Foxit used not to (which was my main reason for using it) but now does. – Chris H Apr 10 '14 at 11:08
  • @ChrisH Good point. Also, SumatraPDF does not lock, and in fact updates on the fly – darthbith Apr 10 '14 at 11:09
  • I do not have the pdf file open while I'm compiling. It has been working perfectly the last 3 months. I use SumatraPDF. – Anders Huntley Apr 10 '14 at 11:11
  • 1
    @darthbith as does evince on linux (though it lacks some nice features of other readers). On windows I use a compile batch file that causes foxit to open a new tab with the latest compile in it - good for comparing output when tweaking - but now it has to muck about with renaming files: http://tex.stackexchange.com/a/126205/28808 – Chris H Apr 10 '14 at 11:11
  • 1
    A few more things to try then: delete the .pdf; delete all other generated files (.aux etc); check the permissions on the folder (is it for example a network location, or some similar case where your permissions could have changed?); copy test.tex to test2.tex and compile that; copy to c:\temp or equivalent and compile there. – Chris H Apr 10 '14 at 11:14
  • When I delete every generated file and move it all to a new location I get following:

    ! I can't write on file `Bachelorprojekt.pdf'. Please type another file name for output ! Emergency stop.

    \edef l.18 \begin{document}
    – Anders Huntley Apr 10 '14 at 11:18
  • What is your OS and how do you compile and where exactly did you store your tex file? – Ulrike Fischer Apr 10 '14 at 11:20
  • Windows 7 64-bit, compile by F6(pdflatex) and F7(view pdf). I stored my tex file on C:\Users\Anders\Desktop\Bachelor Projekt\test.tex – Anders Huntley Apr 10 '14 at 11:22
  • But when you use F7 which viewer does it use? Acrobat? – David Carlisle Apr 10 '14 at 11:27
  • SumatraPDF, but the error occurs when I compile the document, mening when I press F6 :-) – Anders Huntley Apr 10 '14 at 11:29
  • Can you create a PDF with a different name? Does the problem persist if you log out and back in? After a reboot? – Mike Renfro Apr 10 '14 at 12:39
  • I have tried changing the name several times and in different location also. The problem persist when I close all applications or restart the computer. :-) – Anders Huntley Apr 10 '14 at 12:41
  • !!NOTICE!! I worked out the problem. – Anders Huntley Apr 10 '14 at 14:11
  • !!NOTICE!! I worked out the problem. I haven't got a single clue to why this leads to conflict but.. In my introduction I have a table/tabular 3X3 and in the first cell, first line I wrote "[g]" for indicating gram as a unit. This apparently causes the error, since the error doesn't appear when I just write "g". Note that I must delete all generated files before compiling again. The error will keep showing if the generated files are not deleted. :-) Thank you guys for your assistance. – Anders Huntley Apr 10 '14 at 14:18
  • Stupid rule this, that I'm not allowed to answer my own question for the benefit of others. The error can also be fixed by creating a math environment $[g]$. – Anders Huntley Apr 10 '14 at 14:28
  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Martin Schröder Apr 17 '14 at 22:20
  • For this to be a useful question for future visitors it needs to contain code that produces the problem. Currently, you just have a list of packages, and this combination compiles fine in a standard document. Adding the table snippet below from your "Answer" does not produce the described behaviour. – Andrew Swann Oct 01 '14 at 09:16

2 Answers2

6

I have been having a similar problem. It is related to the pdf getting locked by Adobe Reader. Once Adobe opens the file, the compile error occurs. I delete the files (like the questioner), and compile works, but the error returns when I open it again in Adobe. I don't think the [g], as Martin Schroder suggests, was the solution.

Paul
  • 61
  • 1
  • 1
3

!!NOTICE!! I worked out the problem. I haven't got a single clue to why this leads to conflict but.. In my introduction I have a table/tabular and in the first cell, first line I wrote "[g]" for indicating gram as a unit.

\begin{table}
\centering
\caption{Recipes for initial experiments}
\begin{tabular}{lcc}
\toprule
[g]& 5$\%$ cement sub. & 10$\%$ sand sub.\\
\midrule
Water & 225 & 275\\
Sand & 1350 & 1215\\
Cement & 427.5 & 450\\
Ash & 22.5 & 135\\
\bottomrule
\label{opskrift}
\end{tabular}
\end{table}

This apparently causes the error, since the error doesn't appear when I just write "$[g]$".

 \begin{table}
    \centering
    \caption{Recipes for initial experiments}
    \begin{tabular}{lcc}
    \toprule
    $[g]$& 5$\%$ cement sub. & 10$\%$ sand sub.\\
    \midrule
    Water & 225 & 275\\
    Sand & 1350 & 1215\\
    Cement & 427.5 & 450\\
    Ash & 22.5 & 135\\
    \bottomrule
    \label{opskrift}
    \end{tabular}
    \end{table}

Note that I must delete all generated files before compiling again. The error will keep showing if the generated files are not deleted. :-) Thank you guys for your assistance.

egreg
  • 1,121,712