tag:support.fletcherpenney.net,2013-02-12:/discussions/questions/3221-can-mmd6-latex-support-files-be-tweaked-to-support-exporting-mmd6-in-text-citations-to-biblatex-compatible-commandsMultiMarkdown: Discussion 2019-07-27T18:44:16Ztag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-10T05:27:34Z2019-07-19T18:58:06ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>I was wondering if there is a way to tweak the latex support files for mmd6/MMD Composer so that I can use the mmd syntax for in-text citations such that when exported to a latex file, instead of the natbib \citep or \citet commands preceding the .bib citation tag, the biblatex citation tag \autocite is used (see below).</p>
<p>I would like to be able to write the mmd citation like usual to read:<br>
"This is an idea that needs to be cited [][#Smith2019]." and have the exported Tex file read:<br>
"This is an idea that needs to be cited \autocite{Smith2019}."</p>
<p>I do have the latest MacTex working with TexLive-2019 running on macOS 10.14.5, with the latest version of mmd6 (6.4.0) and MMD Composer, 4.5.12.</p>
<p>Just in case anyone is interested I do have biblatex working (except the mmd6 citation syntax) by:<br>
1. Commenting out <code>\usepackage[sort&compress]{natbib}</code> command and adding in <code>\usepackage[style=nlm, backend=biber]{biblatex}</code> in the shared mmd6-memoir-packages.tex file. ('nlm' is the National Library of Medicine style, but any biblatex style could be used)<br>
2. Adding <code>\addbibresource{MyRefs.bib}</code> before <code>\begin{document}</code> in the mmd6-article-begin.tex file.<br>
3. By commenting out pagebackref <code>%pagebackref</code> in the mmd6-article-begin.tex file. Biblatex does not like this command.<br>
4. Including the in-text citations like this as raw latex code in the mmd file like this: "This is an idea that needs to be cited <code>\autocite{Smith2019}</code>{=latex}."<br>
5. Modifying the Bibliography portion of the shared mmd6-memoir-footer.tex file to look like this:</p>
<pre>
<code>% Bibliography
\printbibliography
%\ifx\bibliocommand\undefined
%\else
% \bibliographystyle{\bibliostyle}
% \bibliocommand
%\fi</code>
</pre></div>glentag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-14T14:23:00Z2019-07-14T14:23:00ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>It's been a few years since I really dug into the core of LaTeX citation commands and syntax.</p>
<p>To completely support what you desire would require modifying the latex support files, and then also the code of MMD itself. <code>\citet</code> and <code>\citep</code>are hardcoded in the <code>latex.c</code> file. You can modify that file to change the LaTeX output as desired.</p>
<p>It shouldn't be hard to do.</p>
<p>Fletcher</p></div>fletchertag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-15T03:41:07Z2019-07-15T03:41:07ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>Thanks! I was thinking along those lines. I wonder if it will be this simple, but I was thinking of substituting \autocite in the lines that involve a "print \citep or \citet" and recompiling.</p></div>glentag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-15T12:25:46Z2019-07-15T12:25:46ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>That is basically the first step I would take. Then test it with your documents and see if anything unexpected happens.</p>
<p>If you do this, I would recommend using git, working off the develop branch on the main repo, and creating your own branch from that. This would allow you to easily update your version whenever I update the main version without having to manually make all my changes. (You could work off master as well, but I don't update master as often, so you would get fixes faster if you work off develop.)</p></div>fletchertag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-15T17:20:33Z2019-07-15T17:20:33ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>Sounds good, I'll check out the newer stuff. By the way,, that simple substitution didn't do it as far as I could tell. After running the newly compiled version with that modified latex.c file, using the mmd citation syntax the exported .tex file still had the natbib citation tags and it appeared to trigger the bibliography commands that are normally in the mmd-article-footer.tex file. Strange, the bibtex/natbib commands in the mmd-article-footer.tex were commented out and the biblatex package replaced the natbib package command as described above in the mmd-packages-memoir.tex file. So I'm wondering if there is another place the bibtex commands are 'coming from'. In any case I'll keep experimenting with your newer stuff. Thanks!</p></div>glentag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-19T19:46:38Z2019-07-20T13:49:09ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>Almost there! I substituted \autocite for \citep and \citet in the latex.c file, recompiled and cp the new multimarkdown binary to \usr\local\bin (before I did that I did a 'mv /usr/local/bin/multimarkdown to /usr/local/bin/multimarkdown-orig' -- just in case), and I ran the new multimarkdown (actually the mmd2tex convenience script) from the command line and I got a nice tex document with \autocite{ref}, using [][#ref].</p>
<p>Two things to do:<br>
1. suppress the \begin{bibliography}{0} commands that appear at the bottom of the exported tex file (it seems to be triggered by [][#ref]).<br>
2. Minor cosmetic: my citation tags have capital first letter first author-year. Currently, the export puts the citation tag in lower case. Not sure if it matters but my .bib file all has captial first letter last name-year for citation tags.</p>
<p>One more question: does MMD Composer look for multimarkdown in /usr/local/bin? Or does it use its own compiled version?</p></div>glentag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-20T02:11:31Z2019-07-20T02:11:31ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>Composer has MMD integrated into the code -- it needs direct access to some of the routines.</p>
<p>F-</p></div>fletchertag:support.fletcherpenney.net,2013-02-12:Comment/474244002019-07-20T13:47:19Z2019-07-20T13:47:19ZCan mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?<div><p>Happy to report I got mmd from the command line working so that I can run biblatex. Essentially commenting out the last section of latex.c disables the automatic natbib bibliography latex code triggered by a mmd citation. And including my .bib file in the BibTex metadata header ensures that whatever is in the square brackets in the text retains its formatting as latex code. I commented out the bibliography command in the mmd-memoir-footer as displayed in my first post above so while the metadata is read it does not add the default latex bibliography code.</p>
<p>I attached the modified latex.c file.</p></div>glen