LaTeX forum ⇒ GeneralPackage incompatibility? Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Posts: 5
Joined: Fri Nov 07, 2014 12:36 am

Package incompatibility?

Postby LarsWa » Sun Dec 27, 2015 10:40 pm

I have a 500 p textbook in LaTeX that I wrote a year ago. After migrating to a new computer (Win 7) I get the error message "!You can't use a prefix with '\begingroup'" on a line \Newassociation{hint}{Hint}{hint} related to the package Answers. When I created the minimal working example below, the error instead showed up at a later - but similar line - \Newassociation{solt}{SolutionTeacher}{solt}. The error seems to be related to what is discussed on an incompatibility between different packages. In the stackexchange-post it was recommended to change the order of the different \usepackage-commands, but that does not help in my case. However, I still have a feeling that my problem is related to package incompatibility, as I do not get the error when I only use the Answers package; nor do I get it when I use the Answers package together with some other packages. The minimal problem seems to be a combination of the four un-commented packages below (answers, mchem, pdfpages, siunitx; found by trial and error).

  1. \documentclass[11pt,twocolumn,twoside]{book}
  2. %---------- PACKAGES ------------------
  3. \usepackage{answers}
  4. %\usepackage{amsthm} %enhanced theorems
  5. %\usepackage{graphicx,epstopdf} %insert graphics and convert eps to pdf
  6. %\usepackage[format=plain,font=small,labelfont=bf,up]{caption} %,textfont=it,up
  7. \usepackage[version=3]{mhchem} %chemical formula
  8. %\usepackage{float} %improved placement of floats
  9. %\usepackage{placeins} %makes it possible to prevent floats from floating past the end of a section
  10. \usepackage{pdfpages} %facilitates the insertion of pdf-pages into document (is not needed when the whole text is in LaTeX)
  11. %\usepackage{makeidx} %index processor
  12. %\usepackage{enumerate} % to make it easy to use for example levels of A, B, C for enumerate
  13. % %\usepackage{dblfloatfix} %makes it possible to use [b] with double column floats
  14. %\usepackage{fixltx2e} %amalgamates figure and table lists for single and double columns
  15. %\usepackage{caption} %to customize captions
  16. \usepackage{siunitx} %proper formatting of numbers and SI-units
  17. %\usepackage{xspace} %used only for fixing spaces in \oC
  18. %\usepackage{textgreek} %to write non-italic Greek letters (in Greek box in Thermodynamics chapter)
  19. %---------- ANSWERS PACKAGE ------------------
  20. %I here create four types of files (the exercises are written where they are given): answers, hints, solutions for the book, and %solutions for the teacher. The solutions for the teacher (those solutions that are not given in the book) are given in solt.txt to be %printed separately.
  21. \newtheorem{Ex}{Exercise}
  22. \Newassociation{ans}{Answer}{ans}
  23. \Newassociation{hint}{Hint}{hint}
  24. \Newassociation{sol}{Solution}{sol}
  25. \Newassociation{solt}{SolutionTeacher}{solt}
  26. \renewcommand{\Answerlabel}[1]{\bf{Answer #1.}}
  27. \renewcommand{\Hintlabel}[1]{\bf{Hint #1.} }
  28. \renewcommand{\Solutionlabel}[1]{\bf{Solution #1.} }
  29. \renewcommand{\SolutionTeacherlabel}[1]{\bf{Solution #1.} }
  30. \begin{document}
  31. %---------- START UP USE OF ANSWERS PACKAGE ------------------
  32. \Opensolutionfile{ans}[ans1] % file for answers
  33. \Opensolutionfile{hint}[hint1] % file for hints
  34. \Opensolutionfile{sol}[sol1] % file for solutions for book
  35. \Opensolutionfile{solt}[sol1t] % file for solutions for teacher
  36. \Writetofile{ans}{Here are answers to the exercises.}
  37. \Writetofile{hint}{Here are hints for the exercises.}
  38. \Writetofile{sol}{Here are solutions to selected exercises.}
  39. \Writetofile{solt}{Solutions for the teacher only.}
  40. \chapter{Heat}
  41. Here is the chapter text about heat.
  42. \section{Exercises}
  43. \Writetofile{ans}{\protect\subsection*{Heat}}
  44. \Writetofile{hint}{\protect\subsection*{Heat}}
  45. \Writetofile{sol}{\protect\subsection*{Heat}}
  46. \begin{Ex}
  47. Heat question X.
  48. \begin{ans}Answer X.\end{ans}
  49. \begin{hint}Hint X.\end{hint}
  50. \begin{sol}Solution X.\end{sol}
  51. \end{Ex}
  53. \begin{Ex}
  54. Heat question Y.
  55. \begin{ans}Answer Y.\end{ans}
  56. \begin{hint}Hint Y.\end{hint}
  57. \begin{solt}Solution Y (for teacher only).\end{solt}
  58. \end{Ex}
  60. \chapter{Biology}
  61. Here is the chapter text about biology.
  62. \section{Exercises}
  63. \Writetofile{ans}{\protect\subsection*{Biology}}
  64. \Writetofile{hint}{\protect\subsection*{Biology}}
  65. \Writetofile{sol}{\protect\subsection*{Biology}}
  67. \begin{Ex} %-------------------
  68. Biology question Z.
  69. \begin{ans}Answer Z.\end{ans}
  70. \begin{hint}Hint Z.\end{hint}
  71. \begin{sol}Solution Z.\end{sol}
  72. \end{Ex}
  74. %---------- ANSWERS PACKAGE ------------------
  75. \Closesolutionfile{ans} % answers
  76. \Closesolutionfile{hint} % hints
  77. \Closesolutionfile{sol} % solutions
  78. \Closesolutionfile{solt} % solutions for teacher
  79. \chapter{Answers}
  80. \input{ans1}\newpage
  82. \chapter{Hints}
  83. \input{hint1}\newpage
  85. \chapter{Solutions}
  86. \input{sol1}
  88. \end{document}


Postby BlackForestrian » Tue Dec 29, 2015 1:08 am

User avatar
Stefan Kottwitz
Site Admin
Posts: 9618
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Dec 29, 2015 1:44 am

Hi Lars,

welcome to the forum!

Can you please post the .log file as attachment here? It would be good if you would add the command \listfiles to your preamble, so the log file would list the package names and versions in addition.

Stefan admin

User avatar
Stefan Kottwitz
Site Admin
Posts: 9618
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Dec 29, 2015 10:25 am

For information, the problem has been solved (cross-post site, link above).

It's caused by a bug which is not present in the newest LaTeX version, so an update would help. A workaround is defining a new dummy counter right before the line where the error happened, as egreg suggested.

Stefan admin

Return to “General”

Who is online

Users browsing this forum: No registered users and 13 guests