3

I would like to create an excerpt from a script that I have TeX'ed as a compendium of the most important statements (theorems & definitions).

The question \input only part of a file has an answer by Will Robertson that supposes the usage of catchfilebetweentags. I did that and it is working just fine, but ...

How do you keep the original numbering?

The above mentioned method using the catchfilebetweentags package allows me to make corrections of errors in the main file and the summary at the same time. For the sake of comparability, I would prefer to have the same numbering also. Though the numbering is reset.


Note: I could imagine a solution by putting a \setcounter{counter}{value} in front of each statement but inside the tags. However, this is a very inconvenient way as it is inelegant and involves much more work.


Edit (MWE):

Taken from this site (by Giacomo Drago)

File that contains tags which should be included

% Equations dictionary
\documentclass[11pt]{article}
\usepackage{amssymb,amsmath}

% Begin document
\begin{document}

%<*eq001>
\begin{equation}
F\left (x_1,\dots,x_n,\frac{\partial u}{\partial x_1},\dots,\frac{\partial u}{\partial x_n},\frac{\partial^2 u}{\partial x_1\partial x_1},\dots,\frac{\partial^2 u}{\partial x_n\partial x_n},\dots
\right)
\end{equation}
%</eq001>

\begin{equation}
    a = b + c
\end{equation}

%<*eq002>
\begin{equation}
u_x=\frac{\partial u}{\partial x}, \quad\quad\quad
u_{xy}=\frac{\partial^2 u}{\partial y \partial x}=\frac{\partial u}{\partial y}\left( \frac{\partial u}{\partial x} \right).
\end{equation}
%</eq002>
% A bunch of other equations...
\end{document}

File that includes

% http://yatb.giacomodrago.com/en/post/3/latex-loading-equations-from-an-external-file.html
\documentclass[a4, 11pt, twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\usepackage{catchfilebetweentags}
\usepackage{blindtext}

\newcommand{\loadeq}[1]{%
   \ExecuteMetaData[equ.tex]{eq#1}%
}


\begin{document}
    \blindtext
    \loadeq{001}
    \blindtext
    \loadeq{002}
    \blindtext
\end{document}
9
  • can you make it more clear by adding examples of two files? and is write18 an option?
    – touhami
    Feb 28, 2016 at 19:19
  • Fpr the counter values see the package xassoccnt package and it's \BackupCounterValues and \RestoreCounterValue features please, as I have shown in my answer to this question: tex.stackexchange.com/questions/245680/… -- please download the bugfixed version (v.0.5a) of xassoccnt from my website.
    – user31729
    Feb 29, 2016 at 4:43
  • @touhami, added MWE (note that my question aims at a theorem counter - in case that changes something). Concerning \write18: I am not familiar with that option, though on first sight it seems like quite some work to set up. I would prefer some out of the box solution with some package.
    – BadAtLaTeX
    Feb 29, 2016 at 15:34
  • @ChristianHupfer , I had a look at your answer there and it looks quite promising. As far as I understood, it is used to insert a complete text with independent numbering. Would that allow to include just a single section or theorem whilst maintaining the numbering ? To make it more clear: I do not want any consecutive numbering, but the numbers that each part had in the original file/pdf. (Even if that means it goes like 1.03, 1.06, 1.07, 1.13, 2.13, 2.01, ...)
    – BadAtLaTeX
    Feb 29, 2016 at 15:43
  • the problem here is that you will have (let say) eq1, <eq 2> and eq2 or how do you plan equation a+b=c will be numbered?
    – touhami
    Feb 29, 2016 at 16:01

1 Answer 1

3

Here is a solution. The idea is to capture almost every thing but display only needed parts

first file (with tags)

\documentclass{amsart}
\usepackage{lipsum}

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}
\begin{document}
%<*tag>
\lipsum[1]
Here we go
%</tag>
%<*atag> 
\begin{definition}
some bla bla
\end{definition}
\begin{theorem}
more bla bla
\end{theorem}
\begin{definition}
some bla bla
\end{definition}
%</atag>
%<*btag>
\begin{definition}
some bla bla
\end{definition}
\begin{theorem}
more bla bla
\end{theorem}
%</btag>
%<*ctag>
\lipsum[1-2]
%</ctag>
%<*dtag>
\begin{lemma}
more bla bla
\end{lemma}
\begin{theorem}
more bla bla
\end{theorem}
%</dtag>
%<*etag>
\lipsum[1-2]
\begin{example}
some bla bla
\end{example}
%</etag>
\begin{theorem}
more bla bla
\end{theorem}
\end{document}

final file

\documentclass{amsart}
\usepackage{lipsum}

\usepackage{catchfilebetweentags}
\newtoks\temptoken

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}
\begin{document}
\lipsum[1]
\CatchFileBetweenTags\temptoken{file}{tag}% capture part1
\setbox0=\vbox{\the\temptoken}%  skip part1
\CatchFileBetweenTags\temptoken{file}{atag}% capture part2
\the\temptoken % display part2

\CatchFileBetweenTags\temptoken{file}{btag}% capture part3
\setbox0=\vbox{\the\temptoken}%  skip part3
\CatchFileBetweenTags\temptoken{file}{ctag}% capture part4
\setbox0=\vbox{\the\temptoken}%  skip part4

\CatchFileBetweenTags\temptoken{file}{dtag}% capture part5
\the\temptoken%  display part5
\end{document}

enter image description here

12
  • I've tried your solution with a slight adjustment, that was having all statements use the theorem counter. It seems to work :), really nice. Could you maybe elaborate on how this works ? Especially the difference between \ExecuteMetaData[file]{tag} and your \CatchFileBetweenTags\temptoken{file}{dtag} and the \setbox as well as \temptoken (your comments say it shoul display part 2 only).
    – BadAtLaTeX
    Feb 29, 2016 at 17:40
  • @hillbilly ok i will try
    – touhami
    Feb 29, 2016 at 17:48
  • catchfilebetweentags package define 3 commands (6 if starred version) \CatchFileBetweenTags to be used as above \CatchFileBetweenTags\temptoken{file}{dtag} where \temptoken is toks register or a macro command where the content is saved in case of toks register (as above) we need \the\toksrigstername to display the content.
    – touhami
    Mar 1, 2016 at 17:12
  • \ExecuteMetaData[file]{tag} is equivalent to \CatchFileBetweenTags\temptoken{file}{tag}\the\temptoken i.e. it capture the content and display it immediatly.
    – touhami
    Mar 1, 2016 at 17:24
  • the command \CatchFileBetweenDelims is similar (with slight difference) to \CatchFileBetweenTags please see documentation.
    – touhami
    Mar 1, 2016 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .