{"action":"created","issue":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/775","repository_url":"https://api.github.com/repos/josdejong/mathjs","labels_url":"https://api.github.com/repos/josdejong/mathjs/issues/775/labels{/name}","comments_url":"https://api.github.com/repos/josdejong/mathjs/issues/775/comments","events_url":"https://api.github.com/repos/josdejong/mathjs/issues/775/events","html_url":"https://github.com/josdejong/mathjs/issues/775","id":201668311,"number":775,"title":"Custom latex output for integrated functions","user":{"login":"h1ps","id":18296877,"avatar_url":"https://avatars.githubusercontent.com/u/18296877?v=3","gravatar_id":"","url":"https://api.github.com/users/h1ps","html_url":"https://github.com/h1ps","followers_url":"https://api.github.com/users/h1ps/followers","following_url":"https://api.github.com/users/h1ps/following{/other_user}","gists_url":"https://api.github.com/users/h1ps/gists{/gist_id}","starred_url":"https://api.github.com/users/h1ps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h1ps/subscriptions","organizations_url":"https://api.github.com/users/h1ps/orgs","repos_url":"https://api.github.com/users/h1ps/repos","events_url":"https://api.github.com/users/h1ps/events{/privacy}","received_events_url":"https://api.github.com/users/h1ps/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-18T19:24:52Z","updated_at":"2017-01-18T19:49:40Z","closed_at":null,"body":"Hi,\r\n\r\nis it possible to overwrite the build in _toTex()_ function for your math functions?\r\n\r\nI know that i can import own functions and for this i can create own _toTex()_  for example: \r\n\r\n```javascript\r\nfunction foo() {}\r\nfoo.toTex = function(node,options){\r\n   return \" some latex code\"\r\n}\r\nmath.import({foo: foo})\r\n```\r\n\r\nbut if i try it for example for the _sum_ function like \r\n```javascript\r\n\r\nsum.toTex = function(node,options){\r\n   return \" some latex code\"\r\n}\r\nmath.import({sum: sum})\r\n```\r\nthis doesn't work.\r\n\r\n Thanks in advance!"},"comment":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/comments/273581425","html_url":"https://github.com/josdejong/mathjs/issues/775#issuecomment-273581425","issue_url":"https://api.github.com/repos/josdejong/mathjs/issues/775","id":273581425,"user":{"login":"FSMaxB","id":4294942,"avatar_url":"https://avatars.githubusercontent.com/u/4294942?v=3","gravatar_id":"","url":"https://api.github.com/users/FSMaxB","html_url":"https://github.com/FSMaxB","followers_url":"https://api.github.com/users/FSMaxB/followers","following_url":"https://api.github.com/users/FSMaxB/following{/other_user}","gists_url":"https://api.github.com/users/FSMaxB/gists{/gist_id}","starred_url":"https://api.github.com/users/FSMaxB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FSMaxB/subscriptions","organizations_url":"https://api.github.com/users/FSMaxB/orgs","repos_url":"https://api.github.com/users/FSMaxB/repos","events_url":"https://api.github.com/users/FSMaxB/events{/privacy}","received_events_url":"https://api.github.com/users/FSMaxB/received_events","type":"User","site_admin":false},"created_at":"2017-01-18T19:49:40Z","updated_at":"2017-01-18T19:49:40Z","body":"You can always just override `toTex` directly.\r\n\r\n```js\r\nmath.sum.toTex = function () {\r\n  return \"some latex\";\r\n}\r\n\r\nmath.parse(\"sum()\").toTex(); // -> \"some latex\"\r\n```\r\n\r\nIn theory you should be able to pass a custom handler to `toTex` like the following, but it doesn't seem to work for some reason, not sure what is going on:\r\n```js\r\ncustomToTex = function () {\r\n  return \"some latex\";\r\n}\r\n\r\nmath.parse(\"sum()\").toTex({sum: { handler: customToTex}}); //sadly doesn't work\r\n```\r\n\r\nMaybe I'm doing something wrong (which would be pathetic because I'm the one who implemented that feature).\r\n\r\nYou should also be able to override the `sum` function completely, including custom `toTex` handling. This requires that you pass `{override: true}` as option parameter to `import`."}}
{"actor":{"display_login":"FSMaxB"}}