Chemnum não substituirá marcadores TMP em arquivos EPS

Chemnum não substituirá marcadores TMP em arquivos EPS

Sou novo no látex, mas gostaria muito de usá-lo para escrever minha dissertação (química, obviamente). O trabalho de laboratório está quase pronto, mas esse parece ser o menor obstáculo agora: D

No momento, estou tentando usar o pacote chemnum para obter rótulos legais para todos os compostos. Teoricamente, ele deveria substituir os marcadores "TMP" (que são fornecidos em um arquivo eps externo criado pelo software chemdraw) por numerações automatizadas. No entanto, não consigo executar o arquivo de exemplo usando o TeXstudio:

https://de.overleaf.com/latex/templates/automatically-numbering-compounds-in-chemical-schemes/kybckmsxnshs

No meu caso, os marcadores não são substituídos, mas em todos os seis compostos exemplares está escrito o texto "TMP1" ou "TMP2". Além disso, a fonte dentro das imagens está bagunçada em relação ao modelo pdf acima.

O que estou fazendo de errado? E já que estamos nisso: como faço meus próprios rótulos TMP? posso apenas escrever "TMP" como um bloco de texto no chemdraw?

Desde já, obrigado!

Responder1

Então, recebi uma pista adicional: pode ter a ver com as configurações de compilação.

Conforme afirmado anteriormente, a compilação funciona online usando o texmaker no verso. Overleaf usa compilação de látex, mas quando alterado para pdflatex ele não consegue replacar os marcadores TMP, no entanto, a figura ainda parece correta. Minha configuração já falha ao representar a imagem (veja a captura de tela abaixo, observe que partes aleatórias estão faltando/movidas e a fonte foi alterada).

usar o comando auto-pst-pdf não fornece nenhuma imagem.

enter\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\title{Automatically numbering compounds in chemical schemes}
%% Uncomment these lines if you get error about "too many \new..." 
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}
% For positioning the scheme captions at the top.
\floatsetup[scheme]{position=top}

\begin{document}
\begin{scheme}
%% hexa.eps has "TMP1" and "TMP2" as the markers
%% in fact EVERY .eps should start with TMP1, TMP2 etc
%% for ease of use \replacecmpd{first:compound}  
%% automatically replace TMP1
\replacecmpd{DSV}  %% automatically replace TMP2
\includegraphics[width=\linewidth]{Picture}
\caption{This is something!}
\label{first:chem:scheme}
\end{scheme}
Compounds \refcmpd{first:compound} and \refcmpd{DSV} in \ref{first:chem:scheme}. Here's a reference to in-text creation of \cmpd{RareCompound} that we can later refer to.
\vfill
\end{document}

insira a descrição da imagem aqui

insira a descrição da imagem aqui

Responder2

Os problemas que você está descrevendo são um problema comum na combinação pdfLatex/chemnum/Texstudio/ChemDraw. A numeração composta é obviamente muito poderosa em uma tese de química.

Minha resposta baseia-se nas respostas a perguntas semelhantes, veja:Numeração/ChemDraw/Mac,EPS/ChemDraw/chemnum,configuração correta do Textstudio,

Tentarei listar a seguir as fontes mais comuns de erros:

  1. Compilação: você precisa usar pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.texno TexStudio

  2. Texstudio PATH: Dependendo do seu sistema operacional, defina seu PATH para algo parecido /usr/local/texlive/2019/bin/x86_64-darwin:/Library/TeX/texbin(você terá que adaptar dependendo do seu sistema operacional).

  3. Auto-pst-pdf: você precisará carregar \usepackage[crop=off,runs=2]{auto-pst-pdf}bem no início do seu preâmbulo.

  4. EPS: Precisa ser feito de forma que as strings de texto sejam claramente definidas como tal. O ChemDraw no Windows funciona bem (parâmetros padrão para exportação), mas não o ChemDraw no Mac. Isso é um bug e umpergunta anteriorolhei para isso. Já que consegui compilar seu MWE, acho que você está bem.

Não sei sobre o comentário do nome do trabalho anteriormente, não precisava dele para o TexStudio, mas pode ser necessário para o Overleaf?

Este exemplo funcionou para mim usando as configurações descritas acima, usando o TexStudio v3:

\documentclass{article}
%\def\jobname{main} %<-- your file name
\usepackage[
runs=2,
crop=off
]{auto-pst-pdf} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}

\title{Automatically numbering compounds in chemical schemes}


%% Uncomment these lines if you get error about "too many \new..." 
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}

% For positioning the scheme captions at the top.
%\floatsetup[scheme]{position=top}

    \begin{document}
    
    \begin{scheme}
    %% hexa.eps has "TMP1" and "TMP2" as the markers
    %% in fact EVERY .eps should start with TMP1, TMP2 etc
    %% for ease of use
    \replacecmpd{first:compound}  %% automatically replace TMP1
    \replacecmpd{second:compound}  %% automatically replace TMP2
    \includegraphics[width=\linewidth]{hexa}
    \caption{This is something!}
    \label{first:chem:scheme}
    \end{scheme}
    
    Compounds \refcmpd{first:compound} and \refcmpd{second:compound} in \ref{first:chem:scheme}. Here's a reference to in-text creation of  \cmpd{RareCompound} that we can later refer to.
    
    \vfill
    
    \begin{scheme}
    \replacecmpd{next:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 3!
    \replacecmpd{last:compound} %% automatically replace TMP2
    \includegraphics[width=\linewidth]{hexa}
    \caption{This is something else!}
    \label{second:chem:scheme}
    \end{scheme}
    
    Compounds \refcmpd{next:compound} and \refcmpd{last:compound} in \ref{second:chem:scheme}. Hey remember \cmpd{RareCompound}? \texttt{chemnum} still remembers it correctly, \emph{and} see how the compound numbering continues throughout the scheme diagrams!
    
    \vfill
    
    %% MANUAL UPDATING THE COMPOUND COUNTER; make sure you know what you're doing!
    \setcounter{cmpdmain}{8} 
    
    \begin{scheme}
    \replacecmpd{jumped:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 9!
    \replacecmpd{nextjumped:compound} %% automatically replace TMP2
    \includegraphics[width=\linewidth]{hexa}
    \caption{This is again something else!}
    \label{third:chem:scheme}
    \end{scheme}
    
    Compounds \refcmpd{jumped:compound} and \refcmpd{nextjumped:compound} in \ref{third:chem:scheme}. (Yes we manually modified the compound numbering counter after \ref{second:chem:scheme}).
    \end{document}

insira a descrição da imagem aqui

Responder3

Não tenho reputação de comentar sua resposta. Se você ainda quiser usar o pdflatex como compilador, sugiro renomear o `\jobname´ como Ulrike Fischer fez aqui na respostaaqui.

Usando o exemplo no verso que você citou e adicionando a linha para renomear \jobnamee o {auto-pst-pdf}pacote funciona para mim.

\documentclass{article}
\def\jobname{main} %<-- your file name
\usepackage[
%runs=2,
%crop=off
]{auto-pst-pdf} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}

\title{Automatically numbering compounds in chemical schemes}


%% Uncomment these lines if you get error about "too many \new..." 
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}

% For positioning the scheme captions at the top.
%\floatsetup[scheme]{position=top}

\begin{document}

\begin{scheme}
%% hexa.eps has "TMP1" and "TMP2" as the markers
%% in fact EVERY .eps should start with TMP1, TMP2 etc
%% for ease of use
\replacecmpd{first:compound}  %% automatically replace TMP1
\replacecmpd{second:compound}  %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something!}
\label{first:chem:scheme}
\end{scheme}

Compounds \refcmpd{first:compound} and \refcmpd{second:compound} in \ref{first:chem:scheme}. Here's a reference to in-text creation of  \cmpd{RareCompound} that we can later refer to.

\vfill

\begin{scheme}
\replacecmpd{next:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 3!
\replacecmpd{last:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something else!}
\label{second:chem:scheme}
\end{scheme}

Compounds \refcmpd{next:compound} and \refcmpd{last:compound} in \ref{second:chem:scheme}. Hey remember \cmpd{RareCompound}? \texttt{chemnum} still remembers it correctly, \emph{and} see how the compound numbering continues throughout the scheme diagrams!

\vfill

%% MANUAL UPDATING THE COMPOUND COUNTER; make sure you know what you're doing!
\setcounter{cmpdmain}{8} 

\begin{scheme}
\replacecmpd{jumped:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 9!
\replacecmpd{nextjumped:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is again something else!}
\label{third:chem:scheme}
\end{scheme}

Compounds \refcmpd{jumped:compound} and \refcmpd{nextjumped:compound} in \ref{third:chem:scheme}. (Yes we manually modified the compound numbering counter after \ref{second:chem:scheme}).
\end{document}

Responder4

Procure esta postagem se você estiver usando Chemdraw no MacOS: https://tex.stackexchange.com/a/687480/298255

Esta solução também pode ser útil para usuários do Windows.

informação relacionada