HumanReadableLogsHints.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. import PropTypes from 'prop-types'
  2. import packageSuggestions from './HumanReadableLogsPackageSuggestions'
  3. function WikiLink({ url, children }) {
  4. if (window.wikiEnabled) {
  5. return (
  6. <a href={url} target="_blank" rel="noopener">
  7. {children}
  8. </a>
  9. )
  10. } else {
  11. return <>{children}</>
  12. }
  13. }
  14. WikiLink.propTypes = {
  15. url: PropTypes.string.isRequired,
  16. children: PropTypes.node.isRequired,
  17. }
  18. const hints = {
  19. hint_misplaced_alignment_tab_character: {
  20. extraInfoURL:
  21. 'https://www.overleaf.com/learn/Errors/Misplaced_alignment_tab_character_%26',
  22. formattedContent: () => (
  23. <>
  24. You have placed an alignment tab character '&' in the wrong place. If
  25. you want to align something, you must write it inside an align
  26. environment such as \begin
  27. {'{align}'} … \end
  28. {'{align}'}, \begin
  29. {'{tabular}'} … \end
  30. {'{tabular}'}, etc. If you want to write an ampersand '&' in text, you
  31. must write \& instead.
  32. </>
  33. ),
  34. },
  35. hint_extra_alignment_tab_has_been_changed: {
  36. extraInfoURL:
  37. 'https://www.overleaf.com/learn/Errors/Extra_alignment_tab_has_been_changed_to_%5Ccr',
  38. formattedContent: () => (
  39. <>
  40. You have written too many alignment tabs in a table, causing one of them
  41. to be turned into a line break. Make sure you have specified the correct
  42. number of columns in your{' '}
  43. <WikiLink url="https://www.overleaf.com/learn/Tables">table</WikiLink>.
  44. </>
  45. ),
  46. },
  47. hint_display_math_should_end_with: {
  48. extraInfoURL:
  49. 'https://www.overleaf.com/learn/Errors/Display_math_should_end_with_$$',
  50. formattedContent: () => (
  51. <>
  52. You have forgotten a $ sign at the end of 'display math' mode. When
  53. writing in display math mode, you must always math write inside $$ … $$.
  54. Check that the number of $s match around each math expression.
  55. </>
  56. ),
  57. },
  58. hint_missing_inserted: {
  59. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Missing_$_inserted',
  60. formattedContent: () => (
  61. <>
  62. <p>
  63. You need to enclose all mathematical expressions and symbols with
  64. special markers. These special markers create a ‘math mode’.
  65. </p>
  66. <p>
  67. Use <code>$...$</code> for inline math mode, and <code>\[...\]</code>
  68. or one of the mathematical environments (e.g. equation) for display
  69. math mode.
  70. </p>
  71. <p>
  72. This applies to symbols such as subscripts ( <code>_</code> ),
  73. integrals ( <code>\int</code> ), Greek letters ( <code>\alpha</code>,{' '}
  74. <code>\beta</code>, <code>\delta</code> ) and modifiers{' '}
  75. <code>{'(\\vec{x}'}</code>, <code>{'\\tilde{x}'})</code>.
  76. </p>
  77. </>
  78. ),
  79. },
  80. hint_reference_undefined: {
  81. extraInfoURL:
  82. 'https://www.overleaf.com/learn/Errors/There_were_undefined_references',
  83. formattedContent: () => (
  84. <>
  85. You have referenced something which has not yet been labelled. If you
  86. have labelled it already, make sure that what is written inside \ref
  87. {'{...}'} is the same as what is written inside \label
  88. {'{...}'}.
  89. </>
  90. ),
  91. },
  92. hint_there_were_undefined_references: {
  93. extraInfoURL:
  94. 'https://www.overleaf.com/learn/Errors/There_were_undefined_references',
  95. formattedContent: () => (
  96. <>
  97. You have referenced something which has not yet been labelled. If you
  98. have labelled it already, make sure that what is written inside \ref
  99. {'{...}'} is the same as what is written inside \label
  100. {'{...}'}.
  101. </>
  102. ),
  103. },
  104. hint_citation_on_page_undefined_on_input_line: {
  105. extraInfoURL:
  106. 'https://www.overleaf.com/learn/Errors/Citation_XXX_on_page_XXX_undefined_on_input_line_XXX',
  107. formattedContent: () => (
  108. <>
  109. You have cited something which is not included in your bibliography.
  110. Make sure that the citation (\cite
  111. {'{...}'}) has a corresponding key in your bibliography, and that both
  112. are spelled the same way.
  113. </>
  114. ),
  115. },
  116. hint_label_multiply_defined_labels: {
  117. extraInfoURL:
  118. 'https://www.overleaf.com/learn/Errors/There_were_multiply-defined_labels',
  119. formattedContent: () => (
  120. <>
  121. You have used the same label more than once. Check that each \label
  122. {'{...}'} labels only one item.
  123. </>
  124. ),
  125. },
  126. hint_float_specifier_changed: {
  127. extraInfoURL:
  128. 'https://www.overleaf.com/learn/Errors/%60!h%27_float_specifier_changed_to_%60!ht%27',
  129. formattedContent: () => (
  130. <>
  131. The float specifier 'h' is too strict of a demand for LaTeX to place
  132. your float in a nice way here. Try relaxing it by using 'ht', or even
  133. 'htbp' if necessary. If you want to try keep the float here anyway,
  134. check out the{' '}
  135. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  136. float package
  137. </WikiLink>
  138. .
  139. </>
  140. ),
  141. },
  142. hint_no_positions_in_optional_float_specifier: {
  143. extraInfoURL:
  144. 'https://www.overleaf.com/learn/Errors/No_positions_in_optional_float_specifier',
  145. formattedContent: () => (
  146. <>
  147. You have forgotten to include a float specifier, which tells LaTeX where
  148. to position your figure. To fix this, either insert a float specifier
  149. inside the square brackets (e.g. \begin
  150. {'{figure}'}
  151. [h]), or remove the square brackets (e.g. \begin
  152. {'{figure}'}
  153. ). Find out more about float specifiers{' '}
  154. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  155. here
  156. </WikiLink>
  157. .
  158. </>
  159. ),
  160. },
  161. hint_undefined_control_sequence: {
  162. extraInfoURL:
  163. 'https://www.overleaf.com/learn/Errors/Undefined_control_sequence',
  164. formattedContent: details => {
  165. if (details?.length && packageSuggestions.has(details[0])) {
  166. const command = details[0]
  167. const suggestion = packageSuggestions.get(command)
  168. return (
  169. <>
  170. Undefined control sequence. You have used the command{' '}
  171. <code>{command}</code>, which is part of the{' '}
  172. <code>{suggestion.name}</code> package. Make sure to include the
  173. package in your{' '}
  174. <WikiLink url="https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes#The_preamble_of_a_document">
  175. preamble
  176. </WikiLink>{' '}
  177. using <code>{suggestion.command}</code>.
  178. </>
  179. )
  180. }
  181. return (
  182. <>
  183. The compiler is having trouble understanding a command you have used.
  184. Check that the command is spelled correctly. If the command is part of
  185. a package, make sure you have included the package in your preamble
  186. using <code>\usepackage</code>
  187. {'{...}'}.
  188. </>
  189. )
  190. },
  191. },
  192. hint_file_not_found: {
  193. extraInfoURL:
  194. 'https://www.overleaf.com/learn/Errors/File_XXX_not_found_on_input_line_XXX',
  195. formattedContent: () => (
  196. <>
  197. The compiler cannot find the file you want to include. Make sure that
  198. you have{' '}
  199. <WikiLink url="https://www.overleaf.com/learn/Including_images_in_ShareLaTeX">
  200. uploaded the file
  201. </WikiLink>{' '}
  202. and{' '}
  203. <WikiLink url="https://www.overleaf.com/learn/Errors/File_XXX_not_found_on_input_line_XXX.">
  204. specified the file location correctly
  205. </WikiLink>
  206. .
  207. </>
  208. ),
  209. },
  210. hint_unknown_graphics_extension: {
  211. extraInfoURL:
  212. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_graphics_extension:_.XXX',
  213. formattedContent: () => (
  214. <>
  215. The compiler does not recognise the file type of one of your images.
  216. Make sure you are using a{' '}
  217. <WikiLink url="https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_graphics_extension:_.gif.">
  218. supported image format
  219. </WikiLink>{' '}
  220. for your choice of compiler, and check that there are no periods (.) in
  221. the name of your image.
  222. </>
  223. ),
  224. },
  225. hint_unknown_float_option_h: {
  226. extraInfoURL:
  227. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_float_option_%60H%27',
  228. formattedContent: () => (
  229. <>
  230. The compiler isn't recognizing the float option 'H'. Include \usepackage
  231. {'{float}'} in your preamble to fix this.
  232. </>
  233. ),
  234. },
  235. hint_unknown_float_option_q: {
  236. extraInfoURL:
  237. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_float_option_%60q%27',
  238. formattedContent: () => (
  239. <>
  240. You have used a float specifier which the compiler does not understand.
  241. You can learn more about the different float options available for
  242. placing figures{' '}
  243. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  244. here
  245. </WikiLink>{' '}
  246. .
  247. </>
  248. ),
  249. },
  250. hint_math_allowed_only_in_math_mode: {
  251. extraInfoURL:
  252. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_%5Cmathrm_allowed_only_in_math_mode',
  253. formattedContent: () => (
  254. <>
  255. You have used a font command which is only available in math mode. To
  256. use this command, you must be in maths mode (E.g. $ … $ or \begin
  257. {'{math}'} … \end
  258. {'{math}'}
  259. ). If you want to use it outside of math mode, use the text version
  260. instead: \textrm, \textit, etc.
  261. </>
  262. ),
  263. },
  264. hint_mismatched_environment: {
  265. formattedContent: () => (
  266. <>
  267. You have used \begin
  268. {'{...}'} without a corresponding \end
  269. {'{...}'}.
  270. </>
  271. ),
  272. },
  273. hint_mismatched_brackets: {
  274. formattedContent: () => (
  275. <>You have used an open bracket without a corresponding close bracket.</>
  276. ),
  277. },
  278. hint_can_be_used_only_in_preamble: {
  279. extraInfoURL:
  280. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Can_be_used_only_in_preamble',
  281. formattedContent: () => (
  282. <>
  283. You have used a command in the main body of your document which should
  284. be used in the preamble. Make sure that \documentclass[…]
  285. {'{…}'} and all \usepackage
  286. {'{…}'} commands are written before \begin
  287. {'{document}'}.
  288. </>
  289. ),
  290. },
  291. hint_missing_right_inserted: {
  292. extraInfoURL:
  293. 'https://www.overleaf.com/learn/Errors/Missing_%5Cright_insertede',
  294. formattedContent: () => (
  295. <>
  296. You have started an expression with a \left command, but have not
  297. included a corresponding \right command. Make sure that your \left and
  298. \right commands balance everywhere, or else try using \Biggl and \Biggr
  299. commands instead as shown{' '}
  300. <WikiLink url="https://www.overleaf.com/learn/Errors/Missing_%5Cright_inserted">
  301. here
  302. </WikiLink>
  303. .
  304. </>
  305. ),
  306. },
  307. hint_double_superscript: {
  308. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Double_superscript',
  309. formattedContent: () => (
  310. <>
  311. You have written a double superscript incorrectly as a^b^c, or else you
  312. have written a prime with a superscript. Remember to include {'{and}'}{' '}
  313. when using multiple superscripts. Try a^
  314. {'{b ^ c}'} instead.
  315. </>
  316. ),
  317. },
  318. hint_double_subscript: {
  319. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Double_subscript',
  320. formattedContent: () => (
  321. <>
  322. You have written a double subscript incorrectly as a_b_c. Remember to
  323. include {'{and}'} when using multiple subscripts. Try a_
  324. {'{b_c}'} instead.
  325. </>
  326. ),
  327. },
  328. hint_no_author_given: {
  329. extraInfoURL: 'https://www.overleaf.com/learn/Errors/No_%5Cauthor_given',
  330. formattedContent: () => (
  331. <>
  332. You have used the \maketitle command, but have not specified any
  333. \author. To fix this, include an author in your preamble using the
  334. \author
  335. {'{…}'} command.
  336. </>
  337. ),
  338. },
  339. hint_environment_undefined: {
  340. extraInfoURL:
  341. 'https://www.overleaf.com/learn/Errors%2FLaTeX%20Error%3A%20Environment%20XXX%20undefined',
  342. formattedContent: () => (
  343. <>
  344. You have created an environment (using \begin
  345. {'{…}'} and \end
  346. {'{…}'} commands) which is not recognized. Make sure you have included
  347. the required package for that environment in your preamble, and that the
  348. environment is spelled correctly.
  349. </>
  350. ),
  351. },
  352. hint_somethings_wrong_perhaps_a_missing_item: {
  353. extraInfoURL:
  354. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Something%27s_wrong--perhaps_a_missing_%5Citem',
  355. formattedContent: () => (
  356. <>
  357. There are no entries found in a list you have created. Make sure you
  358. label list entries using the \item command, and that you have not used a
  359. list inside a table.
  360. </>
  361. ),
  362. },
  363. hint_misplaced_noalign: {
  364. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Misplaced_%5Cnoalign',
  365. formattedContent: () => (
  366. <>
  367. You have used a \hline command in the wrong place, probably outside a
  368. table. If the \hline command is written inside a table, try including \\
  369. before it.
  370. </>
  371. ),
  372. },
  373. hint_no_line_here_to_end: {
  374. extraInfoURL:
  375. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_There%27s_no_line_here_to_end',
  376. formattedContent: () => (
  377. <>
  378. You have used a \\ or \newline command where LaTeX was not expecting
  379. one. Make sure that you only use line breaks after blocks of text, and
  380. be careful using linebreaks inside lists and other environments.\
  381. </>
  382. ),
  383. },
  384. hint_verb_ended_by_end_of_line: {
  385. extraInfoURL:
  386. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_%5Cverb_ended_by_end_of_line',
  387. formattedContent: () => (
  388. <>
  389. You have used a \verb command incorrectly. Try replacling the \verb
  390. command with \begin
  391. {'{verbatim}'}
  392. …\end
  393. {'{verbatim}'}
  394. .\
  395. </>
  396. ),
  397. },
  398. hint_illegal_unit_of_measure_pt_inserted: {
  399. extraInfoURL:
  400. 'https://www.overleaf.com/learn/Errors%2FIllegal%20unit%20of%20measure%20(pt%20inserted)',
  401. formattedContent: () => (
  402. <>
  403. You have written a length, but have not specified the appropriate units
  404. (pt, mm, cm etc.). If you have not written a length, check that you have
  405. not witten a linebreak \\ followed by square brackets […] anywhere.
  406. </>
  407. ),
  408. },
  409. hint_extra_right: {
  410. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Extra_%5Cright',
  411. formattedContent: () => (
  412. <>
  413. You have written a \right command without a corresponding \left command.
  414. Check that all \left and \right commands balance everywhere.
  415. </>
  416. ),
  417. },
  418. hint_missing_begin_document_: {
  419. extraInfoURL:
  420. 'https://www.overleaf.com/learn/Errors%2FLaTeX%20Error%3A%20Missing%20%5Cbegin%20document',
  421. formattedContent: () => (
  422. <>
  423. No \begin
  424. {'{document}'} command was found. Make sure you have included \begin
  425. {'{document}'} in your preamble, and that your main document is set
  426. correctly.
  427. </>
  428. ),
  429. },
  430. hint_mismatched_environment2: {
  431. formattedContent: () => (
  432. <>
  433. You have used \begin
  434. {'{}'} without a corresponding \end
  435. {'{}'}.
  436. </>
  437. ),
  438. },
  439. hint_mismatched_environment3: {
  440. formattedContent: () => (
  441. <>
  442. You have used \begin
  443. {'{}'} without a corresponding \end
  444. {'{}'}.
  445. </>
  446. ),
  447. },
  448. hint_mismatched_environment4: {
  449. formattedContent: () => (
  450. <>
  451. You have used \begin
  452. {'{}'} without a corresponding \end
  453. {'{}'}.
  454. </>
  455. ),
  456. },
  457. }
  458. if (!window.wikiEnabled) {
  459. Object.keys(hints).forEach(ruleId => {
  460. hints[ruleId].extraInfoURL = null
  461. })
  462. }
  463. export default hints