Can mmd6 latex support files be tweaked to support exporting mmd6 in-text citations to biblatex compatible commands?

glen's Avatar

glen

10 Jul, 2019 05:27 AM

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).

I would like to be able to write the mmd citation like usual to read:
"This is an idea that needs to be cited [][#Smith2019]." and have the exported Tex file read:
"This is an idea that needs to be cited \autocite{Smith2019}."

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.

Just in case anyone is interested I do have biblatex working (except the mmd6 citation syntax) by:
1. Commenting out \usepackage[sort&compress]{natbib} command and adding in \usepackage[style=nlm, backend=biber]{biblatex} in the shared mmd6-memoir-packages.tex file. ('nlm' is the National Library of Medicine style, but any biblatex style could be used)
2. Adding \addbibresource{MyRefs.bib} before \begin{document} in the mmd6-article-begin.tex file.
3. By commenting out pagebackref %pagebackref in the mmd6-article-begin.tex file. Biblatex does not like this command.
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 \autocite{Smith2019}{=latex}."
5. Modifying the Bibliography portion of the shared mmd6-memoir-footer.tex file to look like this:

% Bibliography
\printbibliography

%\ifx\bibliocommand\undefined
%\else
%   \bibliographystyle{\bibliostyle}
%   \bibliocommand
%\fi
  1. glen closed this discussion on 13 Jul, 2019 07:04 PM.

  2. glen re-opened this discussion on 13 Jul, 2019 10:19 PM

  3. glen closed this discussion on 14 Jul, 2019 06:40 AM.

  4. fletcher re-opened this discussion on 14 Jul, 2019 02:23 PM

  5. Support Staff 1 Posted by fletcher on 14 Jul, 2019 02:23 PM

    fletcher's Avatar

    It's been a few years since I really dug into the core of LaTeX citation commands and syntax.

    To completely support what you desire would require modifying the latex support files, and then also the code of MMD itself. \citet and \citepare hardcoded in the latex.c file. You can modify that file to change the LaTeX output as desired.

    It shouldn't be hard to do.

    Fletcher

  6. 2 Posted by glen on 15 Jul, 2019 03:41 AM

    glen's Avatar

    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.

  7. Support Staff 3 Posted by fletcher on 15 Jul, 2019 12:25 PM

    fletcher's Avatar

    That is basically the first step I would take. Then test it with your documents and see if anything unexpected happens.

    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.)

  8. 4 Posted by glen on 15 Jul, 2019 05:20 PM

    glen's Avatar

    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!

  9. 5 Posted by glen on 19 Jul, 2019 07:46 PM

    glen's Avatar

    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].

    Two things to do:
    1. suppress the \begin{bibliography}{0} commands that appear at the bottom of the exported tex file (it seems to be triggered by [][#ref]).
    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.

    One more question: does MMD Composer look for multimarkdown in /usr/local/bin? Or does it use its own compiled version?

  10. Support Staff 6 Posted by fletcher on 20 Jul, 2019 02:11 AM

    fletcher's Avatar

    Composer has MMD integrated into the code -- it needs direct access to some of the routines.

    F-

  11. 7 Posted by glen on 20 Jul, 2019 01:47 PM

    glen's Avatar

    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.

    I attached the modified latex.c file.

  12. glen closed this discussion on 27 Jul, 2019 06:44 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac