• Tidak ada hasil yang ditemukan

Thmtools Users' Guide

N/A
N/A
Nguyễn Gia Hào

Academic year: 2023

Membagikan "Thmtools Users' Guide"

Copied!
46
0
0

Teks penuh

Elementary definitions

Note that in all cases you will need a backend to provide the command \newtheorem with the usual behavior. Throughout this document we will use amstm, and some of the features will not work with the theorem. As a somewhat odd quirk, you can turn off the number if there is only one instance of the type in the document.

Note that this doesn't mix well with the sibling key: how do you count as someone who suddenly doesn't count anymore.

Frilly references

Styling theorems

Declaring new theoremstyles

It's partly a front-end to the amsthmor theorem\ntheoremstyle command, but provides (more or less successfully) settings for both for each. There is one important thing that you can't see in this example: there are more keys that you can switch to. To change the order in which the title, number, and note appear, there is a header format key.

The daring can also try to provide a macro here that uses the commands\NUMBER,\NAME, and\NOTE. However, you can't get around the fact that the headpunct comes at the end, nor the fonts and brackets you choose with the other keys.

Repeating theorems

Lists of theorems

Extended arguments to theorem envi-

In particular, it will show you how to use the included common brackets to extend theorems the way you want them to behave. All of these take an optional argument, the name of the environment, and the new code as a mandatory argument. The hooks are arranged in the following way: first the specific prehead, then the generic.

At the end of the theorem, it's the other way around: first generic, then specific, before and after that\theorem. This means that you can wrap the whole theorem easily by adding hooks before and after the leg. Note that thmtools doesn't look inside\theorem, so you can't get inside header formatting, spacing, punctuation that way.

However, you shouldn't make any assumptions about the optional argument in the preheadhook: it could still be key/value, or it could already be what's posted as a note. This is because the key-trap handling itself is added as part of the headkeys.).

Case in point: the shaded key

Check the documentation for the color pack, but for the 'gray' model I find .97 looks good on my printer, while a darker shade like .92 is needed for good copying. 11\define@key{thmt@shade}{textwidth}{\setlength\shadedtextwidth{#1}}. 12\define@key{thmt@shade}{bgcolor}{\thmt@definecolor{shadethmcolor}{#1}}. 13\define@key{thmt@shade}{rulecolor}{\thmt@definecolor{shaderulecolor}{#1}}. 14\define@key{thmt@shade}{rulewidth}{\setlength\shadeboxrule{#1}}. 15\define@key{thmt@shade}{margin}{\setlength\shadeboxsep{#1}}. 16\define@key{thmt@shade}{padding}{\setlength\shadeboxsep{#1}}. 17\define@key{thmt@shade}{leftmargin}{\setlength\shadeleftshift{#1}}. 18\define@key{thmt@shade}{rightmargin}{\setlength\shaderightshift{#1}}. On the other hand, we would also like to recognize an already defined color name, such as blue.

To handle the latter case, we need to copy the definition of one color to another. colorlet for that, for the color pack, we cross our fingers. Now comes the interesting part: we assume that a simple color name should not be in parentheses, and a color definition starts with an open curly brace. If the second argument to\thmt@definecolor(the key) begins with a parenthesis, then\thmt@def@color will have an empty second argument, separated by the parenthesis from the key.

If the key does not contain an opening parenthesis, \thmt@def@color will drop everything up to {gray}{0.5}. So first the color is defined to be a medium gray, but then it is immediately overwritten with the definition corresponding to the color name.

Case in point: the thmbox key

How thmtools finds your extensions

Vertical space above the theorem, preferably omitted if the theorem is at the top of the page. The vertical space after the theorem can be omitted if the theorem is at the top of the page. This can be used to override the usual "1.1 Theorem (Foo)" style, for example to leave the numbers at the edge or place them after the name.

You will need to provide this if your title starts with an accented character, for example. You will need to provide this if your title starts with an accented character, for example. Enumerated value: one of the keywords yes, no, or if is not unique. The theorem will be numbered, not numbered, or only numbered if it appears more than once in the document.

This code will be executed at the start of the environment, even before the vertical space is added and the header is pressed. This code will be executed at the bottom of the environment, even after the eventual vertical split, but still within the pool defined by the environment.

Known keys to in-document theorems . 14

This chapter consists of the implementation of Thmtools, in case you are wondering how this or that function is implemented.

The main package

Adding hooks to the relevant

If it doesn't exist at this point, we're probably using the ntheorem as a backend, where it goes through the usual theorem mechanism anyway.

The key-value interfaces

Definition of new theorem styles; keys are in opt-arg, although it doesn't make much sense to have any. It doesn't do anything exciting here, it's up to the glue layer to provide keys.

Lists of theorems

The title name is stored in the \listtheoremname macro and is "List of Theorems" by default.

Re-using environments

Actually, we put a label in the environment, so we know it's Lemma 4 on page 4. Because we avoid resetting the label, we see that it is still Lemma 4 on page 4, even though it appears later as well. As in many cases in LATEX, the star means "don't give a number", because we want to keep the original number.

Restrictions

There is also a starred variant of the stable environment, where the first call does not determine the number, but a later unstarred call to \mylemma does. Counter protections: The values ​​of some counters need to be saved, like equation, so we don't get a new number. There's one problem here: we need to remove all references to other counters from\theequation, otherwise your equation could get a number like (3.1) in one place and (4.1) in another section.

The best solution I can find is to override the usual macros that the counter display goes through to check if their argument is the one that should be fully expanded or retained. The following should only be called from within a group, and saniti\thectrm should not be called from within that group, as it needs the original\@arabicet al.

Fixing autoref and friends

Glue code for different backends

Generic tools

A generalized argument parser . 42

This is useful for things like hyperref\autoref, which otherwise can't distinguish between theorems and definitions if they share a common numerator. Don't get confused: the third parameter is ignored here, we always have recursion here, since token\cl@#1 is (hopefully) not\@elt. I don't see the opposite aliases being called hundreds of times anymore, we just unconditionally create\theHctr-macros for the hyperref.

There is no need to store the value again: since we share a counter register, we retrieve the restored value of the original counter.

Tracking occurences: none, one

  • TheoremS (Euclid)

Companion to\setuniqmark: if the uniqmark given in the first argument has been called more than once, execute the second argument, otherwise execute the first argument. Note that no call to \setuniqmark for a given unique mark means that this unique mark is unique. This is a lazy version: we could always say false if we already had two calls to mark this run, but we still need to replay for every ifunique before the first setuniqmark, so why bother.

Helper Macro: A call to this is written to the .aux file the second time we see a uniqmark. It also checks on subsequent runs if the number of uniqmarks drops below two so we need a rerun. This always warns if the setting for this run is not "many" because it was generated by a setmany from the last run.

Gambar

Figure 1.1: Settable parameters of a theorem style.

Referensi

Dokumen terkait

Lines 207 - 209: This seems more like discussion than results, which is fine if the authors want to do a bit of both here, but elsewhere in the results section it felt more