Tag Info

Hot answers tagged

15

So, first let me say that this is probably the most thoroughly researched question I've read so far. Congratulations. I'll be reusing some of David's comments. The hashing algorithm takes the csname as an array of bytes (probably some differences there for XeTeX and LuaTeX, let me focus on 8-bit engines) and computes the sum of csname[i]*2^(len-i) % prime ...


12

The respective TeX code is @<Compute the hash code |h|@>= h:=buffer[j]; for k:=j+1 to j+l-1 do begin h:=h+h+buffer[k]; while h>=hash_prime do h:=h-hash_prime; end So basically each digit gets mapped to some 2^k mod p. Prefixes and postfixes don't actually make the hashing worse, but the somewhat peculiar structure of the hash table means ...


11

Load the hyperref package first, and then set the PDF document properties using \hypersetup: \documentclass{article} \usepackage{hyperref}% http://ctan.org/pkg/hyperref \newcommand{\authors}[1]{ {\renewcommand{\and}{\unskip, }\hypersetup{pdfauthor={#1}}} \author{#1} } \title{My title} \authors{John Doe \and Dark Vador \and Yoda} \begin{document} ...


11

Yes, LaTeX is a good tool to produce such documents. Especially the moderncv class is very nice for resumes. Adding URLs is not a problem in LaTeX. However, there is a certain learning curve involved and it might take you a little while to get your first complex document in the form you want. Nowadays there many editor and tools like latexmk that will help ...


10

The 'classical' way to store values with a key is to use a csname-based approach \def\addvalue#1#2{\expandafter\gdef\csname my@data@#1\endcsname{#2}} \def\usevalue#1{\csname my@data@#1\endcsname} To allow arbitrary material in the key, you can use e-TeX's \detokenize, and also add a test for undefined values if you wish ...


9

For the special case, there is also a cheap solution. \and can be redfined for hyperref's pdfauthor: \documentclass{article} \usepackage{hyperref} \pdfstringdefDisableCommands{\def\and{, }} \newcommand*{\authors}[1]{% \hypersetup{pdfauthor={#1}}% \author{#1}% } \title{Test document} \authors{John Doe\and Dark Vador\and Yoda}% without space before ...


9

The short-term answer is: use token lists nested in a sequence. \RequirePackage{expl3} \ExplSyntaxOn \seq_new:N \l_lines_seq \cs_new:Npn \jb_wrap:n #1 { \exp_not:n { {#1} } } \seq_clear:N \l_lines_seq \seq_set_split:Nnn \l_tmpa_seq { \\ } { a & b \\ c & d } \seq_map_inline:Nn \l_tmpa_seq { \seq_set_split:Nnn \l_tmpb_seq { & } {#1} % use ...


8

You have several unprotected end of lines, which count as spaces. Some of those I added are not really relevant, but it's good practice to add them. \def\newdict #1{% \expandafter\edef\csname #1 \endcsname{#1}% \expandafter\def\csname #1.set \endcsname##1##2{% <-- Important \expandafter\def\csname #1.##1\endcsname{##2}% }% ...


8

Basic Solution: Without more details it is difficult to know if something as simple as this will work for you: You call \myfirstauthor{Kenobi}{General}{1138}, and then to access each member you simply refer to \myfirstauthorName, \myfirstauthorRank, and \myfirstauthorSerialNum: \documentclass{article} \newcommand{\myfirstauthor}[3]{% ...


7

You can also use the pgfkeys library for a slightly different approach, using a key value system, which is designed as a tree structure. First you define a family, \pgfkeys{/combo/.is family} and then the keys, \pgfkeys{/combo left/.store in=\left@c, left/.default=0, right/.store in=\right@c ...} You can set default values: ...


7

Here is a generalized solution similar to Python's tuples in six lines of TeX code. \documentclass{article} \makeatletter \def\tuple#1=(#2 #3 #4){% \expandafter\def\csname#1@1\endcsname{#2} \expandafter\def\csname#1@2\endcsname{#3} \expandafter\def\csname#1@3\endcsname{#4} } \def\xtuple#1#2{% \csname#1@#2\endcsname } \makeatother ...


7

The way that sequences are implemented means that at that level they can be nested (the nested sequences will be distinct from the outer one). However, what is not available is an interface to store or recover the whole of a sequence. \seq_get:NN \l_my_main_seq \l_tmpa_tl % Available \seq_set:NV \l_my_daughter_seq \l_tmpa_tl % Not available. Similarly, ...


7

Well, I guess I can help. :-) Code \documentclass{scrartcl} \usepackage{tikz} \usetikzlibrary{shapes,arrows,calc} \newcommand{\data}{data \nodepart{second} \phantom{null}} \tikzstyle{ptr} = [draw, -latex'] \tikzstyle{head} = [rectangle, draw, text height=3mm, text width=3mm, text centered, node distance=3cm, inner sep=0pt] \tikzstyle{data} = [rectangle ...


5

The real application is almost trivial with xparse and expl3. \documentclass{article} \usepackage{xparse} \usepackage{hyperref} \ExplSyntaxOn \NewDocumentCommand{\authors}{O{,}m} { \legat_authors:nn { #1 } { #2 } } \seq_new:N \g_legat_authors_seq \cs_new_protected:Npn \legat_authors:nn #1 #2 { \seq_gset_split:Nnn \g_legat_authors_seq { #1 } { #2 } ...


5

\documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\definetuple}{mmmm} { \tl_new:c { g_tuple_#1_tl } \tl_gset:cn { g_tuple_#1_tl } { {#2} {#3} {#4} } } \DeclareExpandableDocumentCommand{\extractfromtuple}{mm} { \tl_item:cn { g_tuple_#1_tl } { #2-1 } } \ExplSyntaxOff \begin{document} ...


4

Here is something with lots of different options in action. You can then opt for some library with more specialization towards trees and graphs however I recommend getting used to the TikZ language first before such attempt. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[>=stealth,%some style declarations ...


4

Only an answer based on percusse's fine solution but with some modifications for the styles. I try to get a lighter code. I added a scope to use options for the labels. I removed pos=.5 because it's the value by default. I remove the style myline and I placed the options in the scope. I used the possibility to draw several edges from the same vertex with one ...


4

You can use the bytefield package, developed exactly with the purpose of drawing protocol packet structures. An example taken from the manual: \documentclass[border=10pt,png]{standalone} \usepackage{bytefield} \begin{document} \begin{bytefield}[bitwidth=1.1em]{32} \bitheader{0-31} \\ \begin{rightwordgroup}{RTP \\ Header} \bitbox{2}{V=2} & ...


4

It's possible to do this, the main disadvantage of course is they are global. Having loaded the font you can use other parts of its structure as well. This old TUGBoat paper of Jonathan Fine's discusses using the ligature tables of such fake fonts to encode state machines.


3

%!TEX TS-program = pdftex \catcode`@=11 \long\def\@firstoftwo#1#2{#1} \long\def\@secondoftwo#1#2{#2} \def\first#1{\@firstoftwo#1} \def\last#1{\@secondoftwo#1} \catcode`@=12 \first{{+tokens1+}{--tokens2--}} \last{{+tokens1+}{--tokens2--}} \bye Of course, if you don't have (or want) anything to do with LaTeX. There's no need for \@firstoftwo while ...


3

My answer tries to explain why @soze got that strange result. First of all, when in dot you define colors, you have to use the same syntax of xcolor, thus: fillcolor="grey75" is wrong => fillcolor="gray!75" color="darkorchid3" is wrong again => color="DarkOrchid3" Another thing: the record shape gives me errors for each node, while using shape ...


3

Perhpas the tkz-linknodes package can be useful for your purpose; here's a little schematic example: \documentclass{article} \usepackage{graphicx} \usepackage{tkz-linknodes} \tikzset{ArrowStyle/.style={text=black,shorten >= 15pt,shorten <= 15pt}} \tikzset{LabelStyle/.style={pos=0.25,right,font=\scriptsize}} \tikzset{NodeStyle/.style={inner sep=0pt}} ...


3

With credit to Bruno Le Floch for the idea, here is what I would consider "working for me": \documentclass{standalone} % ONE POSSIBLE SOLUTION \newcommand{\createcontact}[3]{} \newcommand{\extractfirst}[1]{\renewcommand{\createcontact}[3]{##1}#1} \newcommand{\extractsecond}[1]{\renewcommand{\createcontact}[3]{##2}#1} ...


3

Using lambda lists: \documentclass{minimal} \usepackage{lambda} % http://www.ctan.org/pkg/lambda-lists % \def\createcontact#1#2#3{\Listize[#1,#2,#3]} \let\extractfirst\Head \def\extractsecond#1{\extractfirst{\Tail{#1}}} \def\extractthird#1{\extractsecond{\Tail{#1}}} % \newcommand{\myfirstauthor}{\createcontact{Alice}{Munich}{Germany}} ...


3

Proper alignment using listings is possible by setting the font to typewriter (basicstyle=\ttfamily as optional parameter, or by using \lstset): \documentclass{article} \usepackage{filecontents}% http://ctan.org/pkg/filecontents \usepackage{listings}% http://ctan.org/pkg/listings ‚Äč\begin{document} % Taken from ...


2

Since I couldn't get yours to give any output, I changed some definitions around to produce parsed output of the form you requested. \documentclass{article} \usepackage{stringstrings} \renewcommand\and{\textbf{AND}} \newcommand\MYusepackage[2][1]{[#1]\{#2\}\par} \newcommand\MYauthor[1]{#1} \newcommand\authors[1]{% ...


2

1.: LaTeX is a very good tool for creating complex documents. You have to get used to it. But when you are, you will never want thomething other. Very many scientifical docuemnts are writeen in LaTeX. You can add links with the packages hyperref and url. 2.: By now it is very simple. You can just use pdflatex, and you will directly get PDF output.


2

This task seems well suited for the tabstackengine package. While the package can emulate, in many ways, the behavior of the align style environments in math mode, it is, by default, a text stacking package. Thus, you can use an align style syntax (though in macro, not environment form), but do so in text mode. Note: in text mode, non-zero gaps are ...


1

The apa6 documentation says in section 6.5: The apa6 class supports three bibliography packages: biblatex, apacite, and natbib. The biblatex approach is documented in biblatex-apa.pdf and the references therein. The natbib option loads the apacite package, and both variations are documented in apacite.pdf and the references therein. These documents ...



Only top voted, non community-wiki answers of a minimum length are eligible