Weblog Tomasza Przechlewskiego [Zdjęcie T. Przechlewskiego]


scrum
random image [Photo gallery]
Zestawienie tagów
1-wire | 18b20 | 1wire | 2140 | 3rz | adamowicz | afera | alsamixer | amazon | amber | amman | anniversary | antypis | apache | api | applebaum | arm | armenia | astronomy | asus | atom.xml | awk | aws | bachotek | bakłażan | balcerowicz | balta | banan | bash | batumi | berlin | białowieża | białystok | bibtex | bieszczady | birzeit | biznes | blogger | blogging | blosxom | bme280 | bono | borne-sulinowo | breugel | bt747 | budapeszt | budyniowo | budyń | bursztyn | campagnolo | canon | cedewu | chaos | chello | chiller | chillerpl | chown | christophe dominici | chujowetaśmy | ciasto | cmentarz | contour | coronavirus | covi19 | covid | covid19 | cron | css | csv | cukinia | curl | cycling | d54250wykh | darkages | dbi | debian | dejavu | dhcp | dht22 | dia | docbook | dom | dp1500 | ds18b20 | duda | dulkiewicz | dulkiewiczowa | dyndns | dynia | ebay | economy | ecowitt | ekonomia | elka | elm | emacs | emacs23 | english | ep | erasmus | erasmusplus | ess | eu | eurostat | excel | exif | exiftool | f11 | fc | fc11 | fc15 | fc29 | fc5 | fc8 | fedora | fedora21 | fenix | ffmpeg | finepix | firefox | flickr | folau | fontforge | fontspec | fonty | food | fop | forms | foto | france | francja | fripp | froggit | fuczki | fuji | fuse | gammu | garden | garmin | gas | gawk | gazwyb | gdańsk | gdynia | gender | geo | geocoding | georgia | gft | ggplot | ghost | git | github | gmail | gmaps | gnokii | gnus | google | google apps script | googlecl | googleearth | googlemaps | gotowanie | gphoto | gphoto2 | gps | gpsbabel | gpsphoto | gpx | gpx-viewer | greasemonkey | gruzja | grzyby | gus | gw1000 | haldaemon | handbrake | helsinki | hhi | historia | history | hitler | holocaust | holokaust | hp1000se | hpmini | humour | iblue747 | ical | iiyama | ikea | imagemagick | imap | inkscape | inne | internet | j10i2 | javascript | jhead | jifna | jordania | k800i | kajak | kamera | karob | kibbeh | kleinertest | kml | kmobiletools | knuth | kociewie kołem | kod | kolibki | komorowski | konwersja | krutynia | krynki | kuchnia | kurski | kłamstwo | latex | latex2rtf | latex3 | lcd | legend | lenny | lesund | lewactwo | lgbt-folly | liban | liberation | linksys | linux | lisp | lisrel | litwa | lizbona | logika | ltr | lubowla | lwp | lwów | m2wś | malta | mapquest | mapsource | maradona | marchew | marimekko | marvell | math | mathjax | mazury | mbank | mediolan | mencoder | mevo | mex | mh17 | michalak | michlmayr | microsoft | monitor | mp4box | mplayer | ms | msc | mssql | msw | mswindows | mtkbabel | museum | muzyka | mymaps | mysql | mz | nafisa | nanopi | natbib | navin | neapol | nekrolog | neo | neopi | netbook | niemcy | niemieckie zbrodnie | nikon | nmea | nowazelandia | nuc | nxml | oauth | oauth2 | obituary | ocr | odessa | okular | olympus | ooffice | ooxml | opera | osm | otf | otftotfm | other | ov5647 | overclocking | ozbekiston | padwa | palestyna | panoramio | paryż | pdf | pdfpages | pdftex | pdftk | pedophilia | perl | photo | photography | pi | picasa | picasaweb | pim | pine | pis | pit | pizero | plain | plotly | pls | plugin | po | podcast | podlasie | podróże | pogoda | politics | polityka | polsat | portugalia | postęp | powerpoint | połtawa | prelink | problem | propaganda | pseudointeligencja | pstoedit | putin | python | pywws | r | r1984 | radio | random | raspberry | raspberry pi | raspberrypi | raspbian | refugees | relaxng | ridley | router | rower | rowery | roztocze | rpi | rsync | rtf | ruby | rugby | rumunia | russia | rwc | rwc2007 | rwc2011 | rwc2019 | ryga | rzym | salerno | samba | sds011 | selenium | sem | senah | sernik | sheevaplug | sienkiewicz | signature | sikorski | sks | skype | skytraq | smoleńsk | sqlite | srtm | sshfs | ssl | staszek wawrykiewicz | statistcs | statistics | stats | statystyka | stix | stretch | supraśl | suwałki | svg | svn | swanetia | swornegacie | szwajcaria | słowacja | tallin | tbilisi | terrorism | tesseract | tex | texgyre | texlive | thunderbird | tomato | totalnaopozycja | tourism | tramp | trang | transylwania | truetype | trzaskowski | ttf | turcja | turkey | turystyka | tusk | tv | tv5monde | tweepy | twitter | tykocin | typetools | ubuntu | uchodźcy | udev | ue | ukraina | umap | unix | upc | updmap | ups | utf8 | uzbekistan | varia | video | vienna | virb edit | virbedit | vostro | wammu | wdc | wdfs | weather | weathercloud | webcam | webdav | webscrapping | weewx | wenecja | wh2080 | wiedeń | wikicommons | wilno | win10 | windows | windows8 | wine | wioślarstwo | wojna | word | wordpress | wrt54gl | ws1080 | wtyczka | wunderground | ww2 | www | wybory | wybory2015 | włochy | węgry | xemex | xetex | xft | xhtml | xine | xml | xmllint | xsd | xslt | xvidtune | youtube | yum | zaatar | zakopane | zakupy | zawodzie | zdf | zdrowie | zeropi | zgarden | zgony | zprojekt | łeba | łotwa | świdnica | żywność
Archiwum
06/2023 | 02/2023 | 01/2023 | 11/2022 | 10/2022 | 09/2022 | 07/2022 | 06/2022 | 04/2022 | 03/2022 | 02/2022 | 12/2021 | 09/2021 | 03/2021 | 01/2021 | 12/2020 | 11/2020 | 10/2020 | 09/2020 | 08/2020 | 07/2020 | 04/2020 | 03/2020 | 02/2020 | 01/2020 | 12/2019 | 11/2019 | 10/2019 | 09/2019 | 08/2019 | 07/2019 | 06/2019 | 04/2019 | 02/2019 | 01/2019 | 12/2018 | 11/2018 | 10/2018 | 09/2018 | 08/2018 | 07/2018 | 05/2018 | 04/2018 | 03/2018 | 02/2018 | 01/2018 | 11/2017 | 10/2017 | 09/2017 | 08/2017 | 07/2017 | 06/2017 | 05/2017 | 04/2017 | 03/2017 | 02/2017 | 01/2017 | 12/2016 | 11/2016 | 10/2016 | 09/2016 | 08/2016 | 06/2016 | 05/2016 | 04/2016 | 02/2016 | 12/2015 | 11/2015 | 09/2015 | 07/2015 | 06/2015 | 05/2015 | 02/2015 | 01/2015 | 12/2014 | 09/2014 | 07/2014 | 06/2014 | 04/2014 | 02/2014 | 01/2014 | 12/2013 | 11/2013 | 10/2013 | 09/2013 | 08/2013 | 07/2013 | 05/2013 | 04/2013 | 03/2013 | 02/2013 | 01/2013 | 12/2012 | 11/2012 | 10/2012 | 09/2012 | 08/2012 | 07/2012 | 05/2012 | 03/2012 | 02/2012 | 01/2012 | 12/2011 | 11/2011 | 10/2011 | 09/2011 | 08/2011 | 07/2011 | 06/2011 | 05/2011 | 04/2011 | 03/2011 | 02/2011 | 01/2011 | 12/2010 | 11/2010 | 10/2010 | 09/2010 | 08/2010 | 07/2010 | 06/2010 | 05/2010 | 04/2010 | 03/2010 | 02/2010 | 01/2010 | 12/2009 | 11/2009 | 10/2009 | 09/2009 | 08/2009 | 07/2009 | 06/2009 | 05/2009 | 04/2009 | 03/2009 | 02/2009 | 01/2009 | 12/2008 | 11/2008 | 10/2008 | 09/2008 | 08/2008 | 07/2008 | 06/2008 | 05/2008 | 04/2008 | 03/2008 | 02/2008 | 01/2008 | 12/2007 | 11/2007 | 10/2007 | 09/2007 | 08/2007 | 07/2007 |
O stronie
wykorzystywany jest blosxom plus następujące wtyczki: tagging, flatarchives, rss10, lastbuilddatexhtmlmime. Niektóre musiałem dopasować nieco do swoich potrzeb. Więcej o blosxom jest tutaj
Subskrypcja
RSS 1.0
Publikowanie z bazy danych

Absolutnie minimalistyczny przykład wykorzystania LaTeXa do publikowania zawartości bazy danych:

1. Dane są w bazie sqlite (można ją utworzyć/dodawać rekordy w prosty sposób wykorzystując coś co się nazywa sqlitebrowser)

W przykładzie (poniżej) plik kleinertest.db3 zawiera tabelę Kursanci, z której pobierane są pola ImieNazwisko, PlecOcena.

2. Do drukowania uruchamiamy skrypt w języku Perl. Skrypt jest tak prosty że do dopasowania go do konkretnej tabeli nie potrzeba znajomości Perla a wystarczy zdrowy rozsądek (co zmienić zaznaczono @@)

Perl dla Windows do pobrania z https://www.activestate.com/

3. Skrypt uruchamia pdflatexa i drukuje zawartość bazy do pliku pdf

4. Można skomplikować skrypt, np podając argument na wejściu. Dajmy na to nazwisko delikwenta do wydrukowania. Żeby nie drukować wszystkiego. Do tego potrzeba minimalnej znajomości Perla

#!/usr/bin/perl -w
# Potrzebne są moduły Perla DBI DBD-SQLite DBD-SQLite2
#
use strict;
use utf8;
use DBI;

binmode(STDOUT, ":utf8");

my $dbfileName= "kleinertest.db3"; ## @@ nazwa pliku z bazą
my $tmpfileName = "kleinertest.tex"; ## @@ nazwa pliku .tex
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfileName", "", "");

## @@ Pobranie danych z tabeli Kursanci (pola: ImieNazwisko, Plec Ocena)
my $sth = $dbh->prepare("SELECT
   ImieNazwisko,
   Plec,
   Ocena
   FROM Kursanci ");
$sth ->execute();

## PreAmBuła ### ### ### ### ###
open (TEX, ">$tmpfileName");

print TEX "\\documentclass{article}\\usepackage{mydbiprint}\\begin{document}\n";

## MidBuła: drukowanie rekordów z bazy ## ### ### ###
## ImieNazwisko = $r[0], Plec = $r[1], Ocena = $r[2] itd...
while ( my @r = $sth->fetchrow_array() ) {
     print TEX "\\Dyplom{ $r[0] }{$r[1]}{ $r[2] }\n"; ## @@ dopasować do konkretnej tabeli
   }

## PostAmBuła ## ### ### ### ###
print TEX "\\end{document}\n";

$dbh->disconnect || warn "Nie moge zamknac bazy $dbfileName\n";

## TeXowanie pliku: ## ## ### ### ### ### ###
close(TEX);
system("pdflatex", "$tmpfileName");

## koniec 

Przykładowy pakiet mydbiprint.sty:

%% Minimalistyczny szablon do drukowania z bazy
\RequirePackage[utf8]{inputenc}
\RequirePackage{polski}
\RequirePackage{ifthen}
\pagestyle{empty}
\newcommand{\Dyplom}[3]{%%
  \begin{center}\fontsize{30}{40}\selectfont DYPLOM\end{center}
    \ifthenelse{\equal{#2}{K}}
               {\DyplomDlaPani{#1}{#3}}
               {\DyplomDlaPana{#1}{#3}}
 }
\newcommand\DyplomDlaPani[2]{%
   \begin{center}Pani #1\end{center}
  Zdała egzamin z oceną #2\newpage}
\newcommand\DyplomDlaPana[2]{\begin{center}Pan #1\end{center}
    Zdał egzamin z oceną #2\newpage}
\endinput 
url | Fri, 02/06/2017 04:38 | tagi: , , ,
Kolorowy pasek na zadaną długość

Oto prosty kod LaTeXa, który ma w zamierzeniu spowodować wydrukowanie kolorowego paska o długości 44mm:


Rys: rudy pasek
\documentclass{article}
\usepackage{graphicx,color}
\begin{document}
\definecolor{Xrudy}{rgb}{0.8,0.34,0.0}
\colorbox{Xrudy}{\strut\vrule width44mm height1pt}
\end{document}

Niestety kolorowy pasek wcale nie jest długi na 44mm tylko dłuższy (co widać na rysunku obok: rudy pasek jest dłuższy od czarnej kreski, która faktycznie ma 44mm).

Konsultacja z dokumentacją wyjaśnia, że LaTeX dokłada pewne rzeczy od siebie:

\documentclass{article}
\usepackage{graphicx,color}
\begin{document}
\showthe\fboxrule %% wyświetl wartość parametru \fboxrule
\showthe\fboxsep %% wyświetl wartość parametru \fboxsep
\end{document}

Każde \showthe\parametr powoduje że LaTeX, zatrzymuje kompilację wyświetlając na ekranie wartość parametru (aby kontynuować kompilację należy nacisnąć klawisza ENTER):

> 0.4pt.
l.31 \showthe\fboxrule
                      
? 
> 3.0pt.
l.32 \showthe\fboxsep

Czyli ramka ma domyślą grubość 0,4pt a margines wewnętrzny jest szeroki na 3,0 pt.

Aby się pozbyć dodatkowych odstępów należy zapodać:

\fboxsep=0pt

Można sprawdzić, że to faktycznie działa:

\documentclass{article}
\usepackage{graphicx,color}
\begin{document}
\definecolor{Xrudy}{rgb}{0.8,0.34,0.0}
\setbox0\hbox{% zapisujemy do pudełka zero żeby je potem zmierzyć
 \colorbox{Xrudy}{\strut\vrule width44mm height1pt}}
\showthe\wd0 %% szerokość pudełka zero zdefiniowanego wyżej

\fboxsep=0pt
\setbox0\hbox{\colorbox{Xrudy}{\strut\vrule width44mm height1pt}}
\showthe\wd0 
\end{document}

W rezultacie LaTeX wyświetli podczas kompilacji:

> 131.19212pt.
l.30 \showthe\wd0
                 
? 
> 125.19212pt.
l.36 \showthe\wd0

131,19212pt - 125,19212pt = 6,000 pt jak w mordę...

url | Sat, 24/01/2015 20:03 | tagi:
LaTeX: example of a complex titlepage design

Let's start from example preamble:

\documentclass[twoside]{article}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\makeatletter
%% headlines (\@shorttitle/\@shortauthorlist see below):
\fancyhead[RO]{\@shorttitle}
\fancyhead[LE]{\@shortauthorlist}

 ...
\makeatother

% Title (in Polish) and alternate title (in english):
\title{Hemofiltracja i~rewaskularyzacja u~pacjenta 
  z~zespołem sercowo-nerkowym typu 2}
\alttitle{Hemofiltration in patient with cardio-renal syndrome type 2}

% Authors list:
\author{WLUJ}{Janina Kowalska }
\author{CIL}{Zofia Dyrman}
\author{KCW}{Andrzej Jarzyna}
\author{CIL}{Wacław Jarząbek}
\author{CIL}{Krzysztof Chrostowicz}
% Undefined affiliation raises an error:
% \author{DoPX}{Zdzisław Dyrman}

% Affliations list:
\affiliation{WLUJ}{Wydział Lekarski Uniwersytetu Jagiellońskiego 
 -- Collegium Medicum, ul.~św.~Anny 12, 31--008 Kraków}
\affiliation{CIL}{Centrum Interwencyjnego Leczenia Chorób Serca 
 i~Naczyń, KSzS im.~Jana Pawła II, ul. Prądnicka 80, 31--202 Kraków}
\affiliation{KCW}{Klinika Choroby Wieńcowej UJ, Collegium Medicum,
 KSzS im. Jana Pawła II, ul. Prądnicka 80, 31--202 Kraków}
% Extra affiliation raises an error:
% \affiliation{DRS}{Druskienniki, Pendological Department}

% Short versions of title/authors list (defined if title/authors list
% is too long to fit the headlines:
% \shortauthor{Tratata}
% \shorttitle{Fififif}
%
\begin{document}
\maketitle

\end{document}
LaTeX example titlepage
The titlepage

The main problem is long lists of authors and affiliations. There are more authors than affiliations so affiliations are labelled with consecutive numbers and each author is marked with appropriate label indicating his/her affiliation. It can be done manually of course but with the help of a few clever macros the numbers can be computed by LaTeX. This feature can be particularly helpful when for instance just before the (printing house) deadline a very important author (probably professor) insists his affiliation should be 1 not 4 (for example). All is needed to achieve this is to reorder \affiliation declarations.

The resulting document looks like shown in the picture.

The macros used:

%++Authors and affiliations
\newcount \authornumber
\newcount \affiliationnumber
\authornumber=0
\affiliationnumber = 0
%
\def\alttitle#1{\gdef\@alttitle{#1}}%
\def\shortalttitle#1{\gdef\@shortalttitle{#1}}

\def\author#1#2{%
  \global\advance\authornumber\@ne
  \authorAffiliationId{#1}% -- label --
  \authorName{#2}% -- author's name --
}
%
\def\authorAffiliationId#1{%
  \expandafter\def\csname theauthorid\number%
    \authornumber\endcsname {#1}% --author's id--
  %% label defined to check if affiliation exists:--
  \expandafter\def\csname theaffid:#1\endcsname {#1}%
}
%
\def\authorName#1{%
  \expandafter\def\csname theauthor\number%
    \authornumber\endcsname{\ignorespaces#1\unskip}%
  \expandafter\let\csname theauthoraffiliation\number%
    \authornumber\endcsname\relax
}
%
\def\affiliation#1#2{%
  \global\advance\affiliationnumber\@ne
  \expandafter\def\csname theaffiliation \number%
    \affiliationnumber \endcsname {\ignorespaces#2\unskip}%
  \expandafter\edef\csname affid:#1\endcsname {\number\affiliationnumber}%
  %% if defined in class CLS add error mesage:
  %%\@ifundefined{theaffid:#1}{\ClassError{CLS}{**Affiliation undefined: `#1'}\@ehc}{}%
}
%
\def\@author{\@defaultauthorlist}
\def\@affiliation{\@defaultaffiliationlist}
%
\newcount\count@@
%
% Authors/affiliations lists
\def\@defaultauthorlist{%
   \count@=\authornumber
   \count@@=0
   \begingroup
   \loop
   \ifnum\count@>0
      \advance\count@@ by 1
      \ignorespaces\csname theauthor\number%%
         \count@@\endcsname %-- autor's name --
      \edef\@TmP@Aff@Etykieta{\csname theauthorid\number\count@@ \endcsname}%
      % --check if \@TmP@Aff@Etykieta  exists: --
      \@ifundefined{affid:\@TmP@Aff@Etykieta}%
      %% if defined in class CLS add error mesage:
      %%{\ClassError{CLS}{**Brak afiliacji dla \csname theauthor\number%
      %%\count@@\endcsname}\@ehc}%
      %% print out affiliation label (number):
      {$^{\csname affid:\@TmP@Aff@Etykieta\endcsname}$}%
      %--Every author but last is separated by a comma--:
      \ifnum\count@=1\relax\else,\space\fi
      \advance\count@ by -1
   \repeat
   \endgroup
  }
% Short list of authors (w/o affiliations labels) for headlines.
% Simplified version of @defaultauthorlist:
\def\@defaultshortauthorlist{%
   \count@=\authornumber
   \count@@=0
   \begingroup
   \loop
   \ifnum\count@>0
      \advance\count@@ by 1
      \ignorespaces\csname theauthor\number\count@@\endcsname
      \ifnum\count@=1\relax\else,\space\fi
      \advance\count@ by -1
   \repeat
   \endgroup
  }
%
% Affilitions list:
\def\@defaultaffiliationlist{%
   \count@=\affiliationnumber
   \count@@=0
   \begingroup
   \loop
   \ifnum\count@>0
      \advance\count@@ by 1
      $^{\the\count@@}$ %-- affiliation number
      %-- print out the affiliation:
      \ignorespaces\csname theaffiliation \number\count@@\endcsname
      % ++Every affiliation but last is separated by a comma ++ :
      \ifnum\count@=1\relax\else,\space\fi
      % każda afiliacja od nowego wiersza:
      \par
      \advance\count@ by -1
   \repeat
   \endgroup
  }
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% ++SIMPLIFIED titlepage (just to demonstrate macros defined):++
\renewcommand\maketitle{%
  \begin{titlepage}%
    \let\footnotesize\small
    \let\footnoterule\relax
    \let \footnote \thanks
    % ++Title: ++
    \parindent0pt
    \rightskip0pt plus 4em \pretolerance10001
    \leavevmode \noindent
    {\Large \sffamily \bfseries
    \@title\par
    % ++ Optional alternative title:
    \@ifundefined{@alttitle}{}{\vskip9pt%
    \large \sffamily \bfseries \@alttitle \par} }
    \vspace{5mm}
    % ++Authors list:
    {\rightskip 0pt plus6em%
     \@author\par}
    %
    \vspace{30pt}
    % ++Affiliations list
    {\rightskip 0pt plus6em \@affiliation\par}
    %
    % ++Define content for running headers/footers:
    \@ifundefined{@shortauthorlist}{\gdef\@shortauthorlist{\@defaultshortauthorlist}}{}%
    \@ifundefined{@shorttitle}{\gdef\@shorttitle{\@title}}{}%
    \@ifundefined{@shortalttitle}{\gdef\@shortalttitle{\@alttitle}}{}%
    % 
    \thispagestyle{empty}
  \end{titlepage}%
  %
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}%%//maketitle//

\def\shorttitle#1{\gdef\@shorttitle{#1}}
\def\shortauthorlist#1{\gdef\@shortauthorlist{#1}}
\let\shortauthor\shortauthorlist

url | Wed, 27/03/2013 09:02 | tagi: ,
LaTeX: how to highlight some bibliography entries by adding an asterisk before the entry?

Author-year citation style is assumed.

If a bibliography is prepared manually it is as easy as to precede each entry with say \bibAst command. Example:

\newcommand\bibAst{\leavevmode\hbox to0pt{\hss$^\ast$}}

\harvarditem[Bagozzi and Dholakia]{Bagozzi and
  Dholakia}{2006}{bagozzidholakia06}
\bibAst\textsc{Bagozzi, R.~P.,  {\small and} U.~M. Dholakia}  (2006): ``Open
  Source Software User Communities: A Study Of Participation In {L}inux {U}ser
  {G}roups,'' \emph{Management Science}, 52(7), 1099--1115.

If one insists on using BiBTeX one has to mark records which are to be highlighted. It can be done with an extra field (named highlight in the example below):

@Article{bagozzidholakia06,
  title	= "Open Source Software User Communities: A Study Of
   Participation In {L}inux {U}ser {G}roups",
  author	= "Bagozzi, Richard P. and Dholakia, Utpal M.",
  journal	= j-msci,
  pages		= "1099--1115",
  number	= "7",
  volume	= "52",
  year		= "2006",
  highlight     = "Y"
}

Fields unknown to BiBTeX's particular style are omitted, so highlight cause no harm when processed with standard BiBTeX style.

One need to modify BiBTeX style now. This is a two-step procedure. First one has to add highlight to the body of ENTRY function:

ENTRY
 {
  ...
  highlight
 }

Next one has to modify format.authors function. Exact form of a format.authors function is style-dependent. In case of apalike the code looks like:

%FUNCTION {format.authors}
%{ author empty$
%    { "" }
%    { author format.names }
%  if$
%}
% change to:
FUNCTION {format.authors}
{ author empty$
    { "" }
    { highlight empty$
       { author format.names }
       { "{\bibAst}" author format.names * }
       if$
    }
  if$
}

BTW: the meaning of some BiBTeX expressions are as follows: S1 S2 * denotes S1 S2 strings concatenation; L F1 F2 if$ denotes logical if (execute F1 if L is true otherwise execute F2).

The contents of highlight is irrelevant. Sole existence of highlight denotes that the record is highlighted.

NOTE: the style should be more elaborate if some BiBTeX entries starts with something other than authors names.

url | Tue, 26/03/2013 10:29 | tagi: , ,
LaTeX: znaki cięcia/pasery, pakiety crop i fancyhdr

Kol. WP dba żebym nie wyszedł z wprawy w temacie znajomości LaTeXa.

Jakiś czas temu zażyczył sobie znaków cięcia (zwanych także paserami). Znaki cięcia mają określać wielkość kartki papieru jako 290x205mm (prawie A4). Mają być umieszczone na stronie o nietypowych wymiarach 330x250mm.

Używając pakietu crop można powyższe zalecenie zrealizować następująco:

\documentclass{article}

%% Inne pakiety dołączyć tutaj ...

\setlength\paperheight {290mm}\setlength\paperwidth{205mm}
\usepackage[cam,center,width=250truemm,height=330truemm,pdftex]{crop}
%%
%% Kolumna ma być wyśrodkowana na kartce (zalecenie drukarni)
%% Margines wynosi ( \paperwidth -\textwidth )/2
\oddsidemargin 18.5truemm %% dla \textwidth =  168mm
\evensidemargin\oddsidemargin

\begin{document}

...

\end{document}

No i działa. Dokument jest składany XeTeXem; używa w związku z tym pakietów polyglossia, fontspec, xunicode oraz xltxtra. Powyższe pakiety korzystają z kolei ze stada pakietów z l3kernel/l3packages bundles (fragment przyszłej, ciągle tworzonej od 20 bodajże lat, trzeciej wersji LaTeXa -- LaTeX3 project).

Po jakimś czasie okazało się, że nie działa w MikTeX 2.09. Pierwsza (tytułowa) strona jest podniesiona (względem znaków cięcia) o ok 4mm w porównaniu do wszystkich następnych.

Po dłuższym badaniu stwierdzono, że winna jest dwuwierszowa pagina górna znajdująca się na stronie tytułowej. Wydawała się niegroźna i co więcej, dokument był poprawnie kompilowany, ale tylko w dystrybucji TL 2011. Coś zmieniono w zestawie pakietów l3* (których jest dużo jak wiemy) i to te pakiety odpowiadają za błąd.

Żeby obejść problem postanowiłem składać dwuwierszową paginę w pudełko pionowe (\vbox) o wysokości równej wysokości wiersza tekstu:

\setbox0\hbox{\PM@HeaderFont\strut} %% 
\newdimen\PM@HeaderHt \PM@HeaderHt=\ht0
\def\PM@vboxToOneLine#1{\vbox to\PM@HeaderHt{#1\vss}}
%% ^^^^^^^ pudełko o wysokości wiersza tekstu ^^
%% %% ...
\fancypagestyle{plain}{%% zawartość paginy na stronie tytułowej:
\fancyhf{} % 
 %% ...
\fancyhead[L]{\leavevmode 
  \hbox{\PM@vboxToOneLine{\PM@HeaderFont pierwszy-wiersz ... \\
         ... drugi wiersz ...}}} %
\fancyhead[R]{\leavevmode 
   \hbox{\PM@vboxToOneLine{\PM@HeaderFont pierwszy-wiersz ... \\
         ... drugi wiersz ...}}}
%% ...
}

Teraz działa lepiej.

Nawiasem mówiąc dwuwierszowe paginy to kiepski pomysł. W szczególności fancyhdr wyrównuje górne wiersze pagin, co oznacza, że np. kreska pod paginą będzie nie wyrównana jeżeli (przykładowo) lewa pagina jest dwuwierszowa a prawa jednowierszowa. W omawianym przypadku nie ma kreski pod paginą, dwuwierszowa pagina jest zdefiniowana wyłącznie na stronie tytułowej (której układ jest znakomicie różny od pozostałych stron) a i tak skończyło się problemem.

url | Fri, 15/03/2013 08:52 | tagi: ,
Full page insertions without headers/footers

For some time I help WP in editing a journal for which LaTeX is used. The journal uses simple twocolum layout with multicolumn package. For headers/footers fancyhdr package is used. Recently I was asked to enable full page insertions with headers/footers suspended (probably for big advertisements).

The task is not as straightforward as it seems for a novice user of LaTeX. The following naive approach (\thispagestyle inside float environment) usually fails:

\begin{figure*}{p}
\thispagestyle{empty}
 ...
\end{figure}

LaTeX will supress headers/footers on the page at which \thispagestyle command was executed, not on the page at which the float was finally inserted. If the float is moved to the next page(s), headers/footers will be suspended on the wrong page.

Fortunately fancyhdr provides the \iffloatpage macro that can be used to customize headers and footers for pages which contain only floats. The use of \iffloatpage is simple:

\pagestyle{fancy}
%% supress rules
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
\renewcommand{\footrulewidth}{\iffloatpage{0pt}{0.4pt}}
%%
\fancyhead[RO]{\iffloatpage{}{\PM@HeaderFont \@shorttitle}}
\fancyhead[LE]{\iffloatpage{}{\PM@HeaderFont \@shortauthorlist}}
%%
\fancyfoot[RO]{\iffloatpage{}{\PM@FooterFont\thepage}}
\fancyfoot[LE]{\iffloatpage{}{\PM@FooterFont\thepage}}

%% then in the document body:

\begin{figure*}{p}
 %% --stuff to insert-- %%
\end{figure*}

Note: ``private'' (ie. defined in my class) commands \PM@HeaderFont/\PM@HeaderFont set the font for headers/footers and \@shorttitle/\@shortauthorlist insert some content.

url | Sat, 23/02/2013 21:54 | tagi: , ,
Jak formatować dokument klasy svmult

Poproszono mnie o pomoc w konwersji tekstu z MS Worda do LaTeXa formatowanego z użyciem Springerowskiego pakietu svmult (cf. http://www.springer.com/authors/). Na stronie konferencji praktycznie zero wskazówek co i jak za wyjątkiem zalecenia żeby do cytowań/spisu literatury zastosować system Harwardzki.

Problem w tym, że jest kilka co najmniej sposobów tworzenia (zwłaszcza spisu literatury), które będą zgodne z systemem Harwardzkim. Zakładając, że skoro organizatorzy nie podali dokładnie o co im chodzi, to pewnie sami nie wiedzą starałem się ustalić co i jak w dokumentacji pakietu (Nb. zgodnie z sugestią ze strony WWW konferencji).

Na temat wyglądu odsyłaczy bibliograficznych znalazłem co następuje (plik manuscript-guidelines.pdf):

One author: (Miller 1991) or Miller (1991)
Two authors: (Miller and Smith 1994) or Miller and Smith (1994)
Three authors or more: (Miller et al. 1995) or Miller et al. (1995)

Nie za dużo. Nie wiadomo na przykład jak formatować odsyłacze do wielu pozycji ,,na raz'':

(Miller and Smith 1994, Jones 2002, Jordan et al. 2004) albo
(Miller and Smith 1994; Jones 2002; Jordan et al. 2004)

a może jeszcze inaczej?

Na temat formatowania zestawienia cytowanych pozycji jest dużo więcej, ale jest to, że tak powiem informacja niekonkluzywna. Wymienia się po prostu różne możliwe sposoby formatowania (w zdecydowanej większości w systemie cytowania ,,przez numer''). Nie wiadomo, ani który jest ,,ten dobry'', ani nie ma informacji, jak to zaimplementować w LaTeXu. Np. czy wolno używać pakietu natbib? W pliku klasy próbowałem wyszukać natbib -- nie ma. Czyli jakby nie wolno.

W desperacji odkryłem, że w plikach dystrybuowanych z pakietem są szablony BiBteXa a jeden się nawet nazywa spbasic.bst. Po zajrzeniu do środka się okazało, że zawiera on -- w formie komentarza -- całkiem długi tekst na temat ,,jak zastosować system Harwardzki z pakietem natbib i svmult''. Nie ma co -- doskonale udokumentowany pakiet :@. (Albo Neue Deutsche Wirtschaft bynajmniej nie Polnische Wirtschaft tym razem).

Teraz poszło z górki. Się okazało, że pakiet reaguje na opcję natbib -- widocznie klasa ma zaimplementowany trick (widocznie, bo nie sprawdzałem) pn. ,,dodaj do opcji .sty i poszukaj na dysku pliku o takiej nazwie'' (stąd moje wyszukiwania natbib w kodzie klasy skończyły się niepowodzeniem). Aby ustalić jak formatować tzw. ,,pozycje literaturowe'' uruchomiłem bibtexa z ,,reprezentatywnym'' (tj. zawierającym opisy różnych typów publikacji) plikiem .bib (siłą rzeczy -- skoro była to konwersja z MS Worda -- oryginalnej literatury nie miałem w formacie BiBTeX)

Po ustaleniu co jak ma być formatowane, odpowiednio zmieniłem zawartość otoczenia thebibliography. Dla przypomnienia: stosując natbib sposób formatowania odsyłacza należy podać jako parametr opcjonalny polecenia bibitem, np.:

\bibitem[Wang et~al.(2003)]{wangfan2003} 

bez odstępu pomiędzy listą autorów a otwierającym nawiasem okrągłym (o ten odstęp zadba natbib).

Teraz zapytano organizatorów czy tak może być (Ist es gut?). Brak wskazówek na stronie wskazuje, że pytany pewnie sam nie wie ale to nie moje zmartwienie. Odpowiedzieli, że jak najbardziej...

Poniżej szablon dokumentu svmult w przypadku korzystania z odsyłaczy bibliograficznym w systemie Harwardzkim i wpisywania literatury (zawartości otoczenia thebibliography) ,,z palca'':

\documentclass[natbib]{svmult} %% option natbib for author/year bibliography
\usepackage{mathptmx}   % selects Times Roman as basic font
\usepackage{helvet} % selects Helvetica as sans-serif font
%%
%% Zalecenia odnoście sposobu formatowania odsyłaczy 
%% bibliograficznych ("Harvard system"):
%% 1 autor: (Miller 1991) or Miller (1991)
%% 2 autorów: (Miller and Smith 1994) or Miller and Smith (1994)
%% 3 i więcej autorów: (Miller et al. 1995) or Miller et al. (1995)
%% Zalecenie z pliku: manuscript-guidelines-1.0.pdf
%%
%% Aby usunąć domyślny przecinek pomiędzy autorem a rokiem (Miller, 1991)
%% należy zmienić 5-ty argument polecenia  \bibpunct (ustawić na pusty {}):
\bibpunct{(}{)}{,}{a}{}{,}
%%
\begin{document}
%% 
%% We wszystkich tytułach (artykułu, punktów itp.) należy każdy wyraz rozpoczynać 
%% dużą literą za wyjątkiem (a, an, the, on, of, at, to, itd.)
%% Zalecenie z pliku:  authinst.pdf
%%
\title*{DC of Data Streaming with~a~GNG Network} %
\author{Janina Filipowicz and Tadeusz Owsianko}
\institute{Janina Filipowicz \at
Casimir Pulaski University of Technology and Humanities in Radom, 
Higher School of Engineering,
\email{filipj@ut-radom.edu.pl}
\and
Tadeusz Owsianko \at
Universitas Technologiae et Humanistica Radomensis Casimirus Pulaski, 
Faculty of~Materials Science
\email{owsianko@ut-radom.edu.pl}}

\maketitle

\abstract{%%
The paper presents the results of simulation research
concerning the possibility of applying self-learning GNG neural
networks in clustering data from the data streams.
%% Keywords are optional
\keywords{cluster analysis, data streams clustering, GNGN.}
}

\section{Introduction}

One of the problems connected with the analysis of data [...]

\section{Related Work}

[...] They may be divided into four basic groups. The
first group is made of the incremental or online classifiers. These
are such algorithms as the Very Fast Decision Tree algorithm 
(VFDT)~\citep{domingoshulten2000}.
The second group is made of the multi model algorithms such as Ensemble
Classifiers (EC)~\citep{wangfan2003,kranenassent2011}. The
third group of algorithms contains the low granularity Rule Based
Classifier proposed by~\cite{jirayusakulauwatanamongkol2007}. 

In cluster analysis
their applications were studied among others by~\cite{kaufmanrousseeuw1990},
as well as by~\cite{fritzke1994}.

In the study presented below, the data grouping algorithm based on the
self---learning of neural network of the Growing Neural Gas (GNG)
type will be presented. Compared to the classical Fritzke 
algorithm~\citeyearpar{fritzke1994} 
it has been substantially modified. 

\section{Algorithm of a GNG Network}

In the study presented the data grouping algorithm based on the
self-learning of neural network of the Growing Neural Gas (GNG)
type will be presented. Compared to the classical Fritzke 
algorithm~\citeyearpar{fritzke1994} 
it has been substantially modified.

\section{An Experimental Study}

Summing up the results of experiment, it can be said, that the
compatibility of grouping with the known model was very high 
(cf.~table~\ref{t:quality-speed-clusters}). 

\begin{table}[!tbh]
\caption{Quality and speed of learning 
 of~the GNG network\label{t:quality-speed-clusters}}
%%\tabcolsep=.7\tabcolsep
\begin{tabular}{l|rrrrrrrrrrrrrr} \hline
Clusters	        & 2	& 3	& 4	& 5	& 6	& 15   \\ \hline
Mean RAS	        & 0.75	& 0.92	& 0.97	& 0.98	& 0.99	& 0.83 \\
Mean SC	                & 0.50	& 0.74	& 0.86	& 0.91	& 0.93	& 0.76 \\
Mean Time/Iter ($s^{-4}$)& 4.08	& 4.20	& 4.29	& 4.31	& 4.35	& 4.51 \\ \hline
\end{tabular}
\end{table}

[...] The time of single learning iteration of the network depends on the
number of neurons in that network [...]

\section{Concluding Remarks}

It is difficult to determine the threshold value at which the network
should switch from the dynamic into the static phase. The above
mentioned problems will be subject of further research.

\begin{thebibliography}{}

%% Conference proceedings etc:
\bibitem[Domingos and Hulten(2000)]{domingoshulten2000} 
  Domingos P, Hulten G (2000): Mining High-Speed Data Streams. In:
  Proceedings of the sixth ACM SIGKDD International Conference on
  Knowledge Discovery and Data Mining, Boston, pp~71--80.

%% Book 1 author
\bibitem[Fritzke(1994)]{fritzke1994} 
  Fritzke B (1994): Growing Cell
  Structures -- a~Self-Organizing Network for Unsupervised and
  Supervised Learning. Neural Networks 7:1441--1460.

%% Journal article
\bibitem[Jirayusakul and Auwatanamongkol(2007)]{jirayusakulauwatanamongkol2007} 
  Jirayusakul A, Auwatanamongkol S (2007): A Supervised Growing Neural Gas
  Algorithm for Cluster Analysis, International Journal of Hybrid
  Intelligent Systems 4(2):129--141.
%% Book 2 authors
\bibitem[Kaufman and Rousseeuw(1990)]{kaufmanrousseeuw1990} 
  Kaufman L, Rousseeuw PJ (1990) Finding Groups in Data: a~Introduction
  to Cluster Analysis. Wiley, New York.

%% Journal article more than 2 authors:
\bibitem[Kranen et~al.(2011)]{kranenassent2011} 
  Kranen P, Assent I, Baldauf C,  Seidl T (2011) The ClusTree: Indexing
  Micro-Clusters for Anytime Stream Mining. Knowledge and Information
  Systems 29(2):249--272.

%% Conf proceeding more than 3 authors:
\bibitem[Wang et~al.(2003)]{wangfan2003} 
  Wang H, Fan W, Yu PS, HAN J (2003) 
  Mining Concept-Drifting Data Streams Using Ensemble
  Classifiers. In Proceedings of the ninth ACM SIGKDD International
  Conference on Knowledge Discovery and Data Mining, NY, pp~226--235.

\end{thebibliography}
\end{document}

url | Tue, 15/01/2013 10:39 | tagi:
How to use svmult class

I was asked to help to prepare a paper with Springer's svmult class. The conference (held in Germany) organizers refer to http://www.springer.com/authors/ for formatting instructions but these instructions lack one important detail: how to format citations and the bibliography listing.

The editor of the conference the paper is to be submitted insists on using author(s) name(s)/publication year (Harvard) system but bibliography listing conformed to Harvard system can be formatted in several pretty different ways.

I have found the following recommendations concerning references in manuscript-guidelines.pdf:

One author: (Miller 1991) or Miller (1991)
Two authors: (Miller and Smith 1994) or Miller and Smith (1994)
Three authors or more: (Miller et al. 1995) or Miller et al. (1995)

It is not explained (among other things) however how to format multiple citations, ie:

(Miller and Smith 1994, Jones 2002, Jordan et al. 2004) or
(Miller and Smith 1994; Jones 2002; Jordan et al. 2004)

or in some other way?

To figure out the required bibliography format in desperation I decided to run bibtex with spbasic.bst (included in svmult package) and then I have discovered a pretty lengthy comment (inside spbasic.bst) on using svmult and Harvard system. Well documented package :@. Neue Deutsche Wirtschaft?.

The conference organizers were asked if the above is OK. The lack of detailed manuscript guidelines is suspicious (I suspect that person responsible for conference proceedings is not a LaTeX expert) but as they say `OK' the problem seems to be solved.

To save potential users of svmult reinventing the wheel in cases as the one described above:-) here is the template of the manuscript:

\documentclass[natbib]{svmult} %% option natbib for author/year bibliography
\usepackage{mathptmx}   % selects Times Roman as basic font
\usepackage{helvet} % selects Helvetica as sans-serif font
%%
%% cf. manuscript-guidelines-1.0.pdf
%% ---------------------------------
%% Cite references in the text with author name/s and year of 
%% publication in parentheses ("Harvard system"):
%% One author: (Miller 1991) or Miller (1991)
%% Two authors: (Miller and Smith 1994) or Miller and Smith (1994)
%% Three authors or more: (Miller et al. 1995) or Miller et al. (1995)
%%
%% Use the command \bibpunct with one optional and 6 mandatory arguments: 
%% arg 5 -- the punctuation that comes between the author names and the year 
%%   empty argument denotes space between author-name publication-year
\bibpunct{(}{)}{,}{a}{}{,}
%%
\begin{document}
%% 
%% In English texts all words of a heading (\title, \section, \subsection etc) 
%% have a leading capital letter except for articles (a, an, the), 
%% conjunctions and prepositions of up to four letters (e.g. on, of, at, to, etc...)
%% (cf cf. authinst.pdf)
%%
\title*{DC of Data Streaming with~a~GNG Network} %
\author{Janina Filipowicz and Tadeusz Owsianko}
\institute{Janina Filipowicz \at
Casimir Pulaski University of Technology and Humanities in Radom, 
Higher School of Engineering,
\email{filipj@ut-radom.edu.pl}
\and
Tadeusz Owsianko \at
Universitas Technologiae et Humanistica Radomensis Casimirus Pulaski, 
Faculty of~Materials Science
\email{owsianko@ut-radom.edu.pl}}

\maketitle

\abstract{%%
The paper presents the results of simulation research
concerning the possibility of applying self-learning GNG neural
networks in clustering data from the data streams.
%% Keywords are optional
\keywords{cluster analysis, data streams clustering, GNGN.}
}

\section{Introduction}

One of the problems connected with the analysis of data [...]

\section{Related Work}

[...] They may be divided into four basic groups. The
first group is made of the incremental or online classifiers. These
are such algorithms as the Very Fast Decision Tree algorithm 
(VFDT)~\citep{domingoshulten2000}.
The second group is made of the multi model algorithms such as Ensemble
Classifiers (EC)~\citep{wangfan2003,kranenassent2011}. The
third group of algorithms contains the low granularity Rule Based
Classifier proposed by~\cite{jirayusakulauwatanamongkol2007}. 

In cluster analysis
their applications were studied among others by~\cite{kaufmanrousseeuw1990},
as well as by~\cite{fritzke1994}.

In the study presented below, the data grouping algorithm based on the
self---learning of neural network of the Growing Neural Gas (GNG)
type will be presented. Compared to the classical Fritzke 
algorithm~\citeyearpar{fritzke1994} 
it has been substantially modified. 

\section{Algorithm of a GNG Network}

In the study presented the data grouping algorithm based on the
self-learning of neural network of the Growing Neural Gas (GNG)
type will be presented. Compared to the classical Fritzke 
algorithm~\citeyearpar{fritzke1994} 
it has been substantially modified.

\section{An Experimental Study}

Summing up the results of experiment, it can be said, that the
compatibility of grouping with the known model was very high 
(cf.~table~\ref{t:quality-speed-clusters}). 

\begin{table}[!tbh]
\caption{Quality and speed of learning 
 of~the GNG network\label{t:quality-speed-clusters}}
%%\tabcolsep=.7\tabcolsep
\begin{tabular}{l|rrrrrrrrrrrrrr} \hline
Clusters	        & 2	& 3	& 4	& 5	& 6	& 15   \\ \hline
Mean RAS	        & 0.75	& 0.92	& 0.97	& 0.98	& 0.99	& 0.83 \\
Mean SC	                & 0.50	& 0.74	& 0.86	& 0.91	& 0.93	& 0.76 \\
Mean Time/Iter ($s^{-4}$)& 4.08	& 4.20	& 4.29	& 4.31	& 4.35	& 4.51 \\ \hline
\end{tabular}
\end{table}

[...] The time of single learning iteration of the network depends on the
number of neurons in that network [...]

\section{Concluding Remarks}

It is difficult to determine the threshold value at which the network
should switch from the dynamic into the static phase. The above
mentioned problems will be subject of further research.

\begin{thebibliography}{}

%% Conference proceedings etc:
\bibitem[Domingos and Hulten(2000)]{domingoshulten2000} 
  Domingos P, Hulten G (2000): Mining High-Speed Data Streams. In:
  Proceedings of the sixth ACM SIGKDD International Conference on
  Knowledge Discovery and Data Mining, Boston, pp~71--80.

%% Book 1 author
\bibitem[Fritzke(1994)]{fritzke1994} 
  Fritzke B (1994): Growing Cell
  Structures -- a~Self-Organizing Network for Unsupervised and
  Supervised Learning. Neural Networks 7:1441--1460.

%% Journal article
\bibitem[Jirayusakul and Auwatanamongkol(2007)]{jirayusakulauwatanamongkol2007} 
  Jirayusakul A, Auwatanamongkol S (2007): A Supervised Growing Neural Gas
  Algorithm for Cluster Analysis, International Journal of Hybrid
  Intelligent Systems 4(2):129--141.
%% Book 2 authors
\bibitem[Kaufman and Rousseeuw(1990)]{kaufmanrousseeuw1990} 
  Kaufman L, Rousseeuw PJ (1990) Finding Groups in Data: a~Introduction
  to Cluster Analysis. Wiley, New York.

%% Journal article more than 2 authors:
\bibitem[Kranen et~al.(2011)]{kranenassent2011} 
  Kranen P, Assent I, Baldauf C,  Seidl T (2011) The ClusTree: Indexing
  Micro-Clusters for Anytime Stream Mining. Knowledge and Information
  Systems 29(2):249--272.

%% Conf proceeding more than 3 authors:
\bibitem[Wang et~al.(2003)]{wangfan2003} 
  Wang H, Fan W, Yu PS, HAN J (2003) 
  Mining Concept-Drifting Data Streams Using Ensemble
  Classifiers. In Proceedings of the ninth ACM SIGKDD International
  Conference on Knowledge Discovery and Data Mining, NY, pp~226--235.

\end{thebibliography}
\end{document}

BibTeX is not used. Optional argument of \bibitem command should contains text which is used by natbib to format citations. This text should looks like: author-list(year).

url | Tue, 15/01/2013 09:07 | tagi: ,
Kilka trików dotyczących LaTeXa

Parę trików LaTeXa, na które wpadłem w/z ze składanymi ostatnio dokumentami.

Szerokie tabele (lub rysunki) wystające na zewnętrzny margines:

\usepackage{ifoddpage}
%% Istotne są polecenia \unskip i \ignorespaces, inaczej zawartość nie jest
%% wyrównana do wewnętrznego marginesu:
\newenvironment{ShiftToOuterMargin}{\leavevmode 
   \noindent \hbox to\textwidth \bgroup\checkoddpage\unskip \ignorespaces
  \ifoddpage \else\hss\fi}{\ifoddpage\hss\else\fi\unskip\egroup}
%% ... ... ...
\begin{ShiftToOuterMargin}
 \begin{tabular}{|l|rrrr|rrrr|} ...
 \end{tabular}
\end{ShiftToOuterMargin}

Do ustalenia, czy bieżąca strona jest parzysta czy nieparzysta używam pakietu ifoddpage (polecenia \checkoddpage oraz \ifoddpage). Zwykły zapis \ifodd\c@page nie zadziała z oczywistych względów. Więcej na ten temat znajduje się w TeX Frequently Asked Questions.

Zapamiętanie zawartości tekstu składanego literalnie (pakiet fancyvrb; otoczenie SaveVerbatim i polecenie \BUseVerbatim):

\usepackage{fancyvrb}
 %% ... ... ... 
\begin{SaveVerbatim}{VerbEnv}
 ... tekst literalny ...
\end{SaveVerbatim}
\begin{ShiftToOuterMargin}
\BUseVerbatim{VerbEnv}
\end{ShiftToOuterMargin}

Formatowanie przypisów w poprzek reguł LaTeXa: przypis ma być umieszczony w kolumnie tekstu wciętej o wielkość wcięcia akapitowego z lewej strony. Na marginesie (o wielkości wcięcia akapitowego) ma być umieszczony numer odsyłacza. Numer przypisu nie we być złożony we frakcji górnej ale stopniem podstawowym pisma.

Pomysł rozwiązania zgłoszony na GUST-l (autor anonimowy):

\makeatletter
\newdimen \@parindent \@parindent=\parindent
\renewcommand{\@makefntext}[1]{%
	\everypar = {\hangindent = \@parindent \hangafter = 1}{\par}
	\parindent 1.5\@parindent % wcięcie drugiego (i kolejnych) akapitu tego samego długiego przypisu
	\noindent\hb@xt@ \@parindent % 0\@parindent
{\hss\@makefnmark \enspace}#1}
%{\hss{\@thefnmark} \enspace}#1} % do nautycznych
\makeatother

Polecenie \@makefnmark formatuje numer odsyłacza, domyślnie jest to:

\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}

Odsyłacz jest formatowany identycznie w tekście i w kolumnie przypisów. Zamiast tego trzeba zdefiniować formatowanie na dwa sposoby, przykładowo:

%% numer odsyłacza do kolumny tekstu:
\def\@makeTextfnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
%% numer odsyłacza do kolumny przypisów
\def\@makefnmark{\hbox{\normalfont\@thefnmark}}

oraz w definicji \@makefntext zamiast \@makefnmark wstawić \@makeTextfnmark.

url | Tue, 17/07/2012 23:04 | tagi:
Sposoby redagowania odsyłaczy bibliograficznych w schemacie autor-rok

Sposoby redagowania odsyłaczy bibliograficznych w schemacie autor-rok przy pomocy LaTeX-owego pakietu natbib:

F1. Na końcu zdania (najczęściej) w nawiasie, \citep

Ekwiwalencja pomiaru jest ważnym kryterium oceny jakości projektowanych skal pomiarowych (Cheung i Rensvold, 1999; Steenkamp i Baumgartner, 1998).

Co wygląda ,,w źródle'' LaTeXowym następująco:

Ekwiwalencja pomiaru jest ważnym
kryterium oceny jakości projektowanych 
skal pomiarowych~\citep{CheungRensvold1999,SteenkampBaumgartner1998}.

Uwaga: jeżeli podstawową formą odsyłacza jest autor (rok), to wydawać by się mogło, że powinno być:

Ekwiwalencja pomiaru jest ważnym kryterium oceny jakości projektowanych skal pomiarowych (Cheung i Rensvold (1999), Steenkamp i Baumgartner (1998)).

Ale to mi się wizualnie nie podoba, bo mnoży ponad potrzebę nawiasy, no i ten fatalnie wyglądający podwójny nawias na końcu.

F2. Inny wariant, wtrącenie z komentarzem \citealp

koncentruje się raczej na fenomenie jego tworzenia, motywacji twórców, koordynacji itd. (por. Al Marzouq, 2005; Niederman i inni, 2006a, Feller i Fitzgerald, 2002; Niederman i inni 2006a).

koncentruje się raczej na fenomenie jego
tworzenia, motywacji twórców, 
koordynacji itd. (por.~\citealp{AlMarzouq05,Niederman2006a,FellerFitzgerald2002,Niederman2006b}). 

Wreszcie podnoszone są zarzuty dotyczące zbytniej arbitralności proponowanej procedury (por. Straub i inni, 2004, s. 391 oraz Bollen, 1989, s. 192).

Wreszcie podnoszone są zarzuty
dotyczące zbytniej arbitralności proponowanej
procedury (por.~\citealp[s.~391]{StraubBoudreauGefen2004} oraz \citealp[s.~192]{Bollen89}).  

Uwaga: jedna z dwóch form, tj. F1 i F2 wydaje się zbędna(?). Kowal (Metody Statystyczne w badaniach sondażowych rynku, PWN, Warszawa 1998) używa F2, co m.in. powoduje że słowo por. jest przypuszczalnie najczęściej używanym trzyliterowym wyrazem w książce:-)

F3. Wariant powyższego, \citet

Do zastosowania w sytuacji, kiedy nie można umieścić odsyłaczy en-block w nawiasach (czyli zastosować polecenie \citep).

W licznych przeglądach podjęto wiele prób krytyki i oceny stosowanych podejść badawczych, por. Orlikowski i Baroudi (1991), Galliers (1992), Benbasat i Zmud (1999), Vessey i inni (2002), Mingers (2003), Palvia i inni (2004).

W~licznych przeglądach podjęto wiele prób 
krytyki i~oceny stosowanych podejść
badawczych, 
por. \citet{OrlikowskiBaroudi91,Galliers1992,BenbasatZmud99,VesseyGlass2002,Mingers2003,PalviaEtAl2004}.

Uwaga: ta forma wydaje się zbędna(?). Zawsze można cytat umieścić w nawiasie czyli w formie F2).

F4. W tekście z odmianą nazwisk autorów, \citeyearpar

przez Ajzena i Fishbeina (1975) na gruncie psychologii społecznej teorii uzasadnionego...

przez Ajzena i~Fishbeina~\citeyearpar{FishbeinAjzen1975} na gruncie psychologii
społecznej teorii uzasadnionego 

W przeglądach Schepersa i Wetzelsa (2007), Kinga i He (2006) oraz Yousafzai i~innych~(2007b) testowano

W~przeglądach Schepersa i~Wetzelsa~\citeyearpar{SchepersWetzels2007},
Kinga i~He~\citeyearpar{KingHe2006} oraz
Yousafzai i~innych~\citeyearpar{ShumailaetAl2007b}
testowano

Uwaga: Książka Chowa (Ekonometria, PWN, Warszawa 1995) tak została zredagowana, że stosowane są wyłącznie odsyłacze typu F4.

Formy nieregularne:-)

działania będą akceptowane na tak lub nie przez ważne dla tej jednostki osoby'' (por. Ajzen, 1991, s. 302 za Venkateshem i Davisem, 2000, s. 187).

działania będą akceptowane na tak lub nie przez ważne dla tej
jednostki osoby'' por.~\citealp[s.~302]{Ajzen1991} 
za Venkateshem i~Davisem,~\citeyear[s.~187]{VenkateshDavis00}).

Aksjomat Przechlewskiego

Odsyłacze typu F1--F4 można zawsze zredukować do postaci F1 i F4. Tak zredagowane są przykładowo książki: Konarski, Modele równań strukturalnych, PWN, Warszawa 2009; Brzeziński, Metodologia badań psychologicznych, PWN, Warszawa 2004; Gatnar i Walesiak, Analiza danych jakościowych i symbolicznych z wykorzystaniem pakietu R, CH Beck, Warszawa 2011.

Przykłady odnośników autor-rok podane przez Osuchowską (Poradnik redaktora i autora, Wydawnictwo Polskiego Towarzystwa Wydawców Książek, Warszawa 1988, s. 174) także ograniczają się do postaci F1 i F4.

url | Sun, 08/07/2012 12:49 | tagi: ,
Grube greckie litery nie są składane po dołączeniu qtxmath/pxtmath

Już wiem, że pakiety txfonts/pxfonts nie są najwyższej jakości. Teraz się okazało, że zalecane (zapomniałem tylko przez kogo:-) jako uzupełnienie pakiety qtxmath/pxtmath też zawierają błędy:

%& --translate-file=il2-pl
\documentclass{article}
\usepackage{amsmath,bm}
\usepackage[T1]{polski}
\usepackage{txfonts}
\usepackage{tgtermes,qtxmath}
\begin{document}
$\Omega \mathbf{\Omega} $ 
\end{document}

Gube greckie litery są zamieniane na litery łacińskie. Nawet nie chce mi się sprawdzać czemu bo pakiet qtxmath/pxtmath nie zawiera plików źródłówych, z których są generowane fonty tfm/vf. Nie idzie też tych źródłowych plików nigdzie znaleźć.

Po usunięciu qtxmath skład jest poprawny. Z tego co mi się obiło o uszy qtxmath/qpxmath miało poprawiać pakiety txfontspxfonts, ale jak widać nie do końca.

url | Fri, 18/05/2012 10:24 | tagi:
Simple application of fontspec package

The document body font is Times New Roman-like. Sans serif font is Helvetica-like. Both regular and condensed variant of sans serif is used. With fontspec package it can be obtained with:

\RequirePackage{ifxetex} %%
\ifxetex %% xetex
\RequirePackage{fontspec}
\usepackage{polyglossia} \setdefaultlanguage{polish}
\setmainfont{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}
\defaultfontfeatures{Mapping=tex-text}
\newfontfamily\PM@SansCondensed{TeX Gyre Heros Cn} %%
\usepackage{xunicode,xltxtra}
\else %% conventional TeX
\RequirePackage{tgtermes,txfonts,qtxmath} %% txfonts
\def\PM@SansCondensed{\fontfamily{qhvc}}
\fi

With the help of \ifxetex command from ifxetex package the code above works when compiled both with xetex as well as conventional pdflatex.

The example below illustrates how \PM@SectionFont can be used to switch to condensed variant of sans serif:

\renewcommand{\section}{\@startsection{section}{1}{\z@}%
    {-3.5ex \@plus -1ex \@minus -.2ex}%
    {2.3ex \@plus.2ex}%
    {\reset@font 
    \PM@SectionFont 
    \raggedright}}

Finally, a few words how to configure system (a Linux one, BTW strictly speaking MS Windows is not a system) to work with OpenType fonts.

Providing the TeX Gyre fonts package is installed (with tlmgr in case of TeXLive for example) all .otf files are located in ~/2011/texmf-dist/fonts/opentype/public/tex-gyre (where ~ denotes the root of TeXlive distribution).

To add all TeX Gyre fonts to system resources it suffice to create /etc/fonts/local.conf with the following content:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<!-- /etc/fonts/local.conf file for local customizations -->
<fontconfig>
<!-- Font directory list -->

        <dir>/usr/local/texlive/2011/texmf-dist/fonts/opentype/public/tex-gyre</dir>

</fontconfig>

Or similar, if root of TeXlive distribution is not /usr/local/.

Now run as root

fc-cache

Check if everything is OK:

fc-list | grep -i Heros

Information on TeX Gyre Heros should be displayed on screen:

TeX Gyre Heros Cn:style=Bold
TeX Gyre Heros Cn:style=Bold Italic
TeX Gyre Heros:style=Regular
TeX Gyre Heros Cn:style=Regular
TeX Gyre Heros:style=Bold Italic
TeX Gyre Heros:style=Italic
TeX Gyre Heros Cn:style=Italic
TeX Gyre Heros:style=Bold

url | Tue, 06/03/2012 09:11 | tagi: , , ,
Titlepage resets the page count

I was not aware that \titlepage command resets page counter. Have no idea why LaTeX works this way but in result \setcounter{page} is ignored no matter where one inserts it in the source code.

It somehow works if \setounter{page} is executed after \begin{titlepage}... (or \maketitle which uses titlepage) but page number for titlepage is always 1.

Worse: definitely LaTeX would be more user-friendly if it would write such brute actions as page counter resets to log file.

Simple fix is to redefine titlepage environment. For example below is a simplified titlepage environment from article.cls:

\renewenvironment{titlepage}
    {%
      \if@twocolumn
        \@restonecoltrue\onecolumn
      \else
        \@restonecolfalse\newpage
      \fi
      \thispagestyle{empty}%
      %%\setcounter{page}\z@
    }%
    {\if@restonecol\twocolumn \else \newpage \fi
    }

The unwanted \setcounter was commented-out in the code above.

url | Tue, 28/02/2012 23:25 | tagi:
Problemy z updmap w TeXlive 2011

Powtórzyłem procedurę opisaną w Próbowanie fontów STIX, tj.:

otftotfm -a -e qx.enc STIXGeneral.otf STIXGeneral--qx

Powyższe generuje pliki vf/tfm/pfb w odpowiednie podkatalogi katalogu /home/tomek/.texlive2011. Uruchamia nawet program updmap, ale coś tam jest nie tak:

otftotfm -a -e qx.enc STIXGeneral.otf STIXGeneral--q
I had to round some heights by 18.0000000 units.
I had to round some depths by 3.0000000 units.
I had to round some heights by 18.0000000 units.
I had to round some depths by 3.0000000 units.
Config file: "/home/tomek/.texlive2011/texmf-config/web2c/updmap.cfg"
/home/tomek/.texlive2011/texmf-config/web2c/updmap.cfg unchanged.  Map files not recreated.
/opt/tex/bin/updmap: Updating ls-R files.
otftotfm: warning: `updmap --nomkmap --enable Map \
  /home/tomek/.texlive2011/texmf-var/fonts/map/dvips/lcdftools/lcdftools.map; 
  updmap >/dev/null 2>&1' exited with status 1;
otftotfm: warning: run it manually to check for errors

Powtarzam zatem:

$ updmap --nomkmap --enable Map /home/tomek/.texlive2011/texmf-var/fonts/map/dvips/lcdftools/lcdftools.map
updmap --nomkmap --enable Map /home/tomek/.texlive2011/texmf-var/fonts/map/dvips/lcdftools/lcdftools.map
Config file: "/home/tomek/.texlive2011/texmf-config/web2c/updmap.cfg"
/home/tomek/.texlive2011/texmf-config/web2c/updmap.cfg unchanged.  Map files not recreated.
/opt/tex/bin/updmap: Updating ls-R files.
## nie wiem o co chodzi, ale jedziemy dalej
##
$ updmap
updmap
Config file: "/home/tomek/.texlive2011/texmf-config/web2c/updmap.cfg"
 .. .. .. 
ERROR:  The following map file(s) couldn't be found:
	/home/tomek/.texlive2011/texmf-var/fonts/map/dvips/lcdftools/lcdftools.map
Did you run mktexlsr?

updmap nie może zatem odszukać pliku lcdftools.map zadeklarowanego w pliku ~/.texlive2011/texmf-config/web2c/updmap.cfg

Próby ustalenia co jest nie tak zawiodły:

kpsewhich -expand-path  '$TEXFONTMAPS'

Wydruk z powyższego zawiera ~/.texlive2011/texmf-var/fonts/map/dvips/lcdftools a wykonanie mktexlsr nie pomaga.

Skopiowałem zatem lcdftools.map do katalogu systemowego /usr/local/texlive/2011/texmf-var/fonts/map/dvips/updmap. Potem

## jako root
mktexlsr ; 
## jako zwykły użytkownik, bo pliki tfm/vf/pfb są w moim katalogu domowym
updmap

Teraz działa. Wygląda na błąd w TL 2011. Znalazłem nawet w google radę zdesperowanego użytkownika, który radził wywalenie updmap.

url | Fri, 18/11/2011 19:52 | tagi: , ,
Dictionary-style headers in LaTeX

It is pretty simple to define dictionary-style headers in LaTeX. Look at the example below:

\documentclass[twoside]{report}
\usepackage{multicol}

%%% \leftmark/\rightmark inserts appropriate \mark{...} 
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhead{} 
\fancyhead[LE]{\normalfont \small\itshape \rightmark }
\fancyhead[RE]{\normalfont \small\itshape \leftmark }
\fancyhead[RO]{\normalfont \small\itshape \leftmark }
\fancyhead[LO]{\normalfont \small\itshape \rightmark }
\fancyfoot[CO,CE]{\thepage}

\title{Vocabulary layout -- example}

\newcommand{\Entry}[2]{\par \leavevmode
 \ignorespaces\markboth{#1}{#1} #1 #2}

\begin{document}
\maketitle

\begin{multicols}{2}

\Entry{AA BB CC DD00001}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00001 zz.}
\Entry{AA BB CC DD00002}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00002 zz.}
\Entry{AA BB CC DD00003}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00003 zz.}

 ... ... ...

\Entry{AA BB CC DD00299}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00299 zz.}
\Entry{AA BB CC DD00300}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00300 zz.}


\end{multicols}

\end{document}

Crucial commands are \markboth, \leftmark and \rightmark. See also Typesetting a Dictionary with LaTeX.

url | Thu, 13/10/2011 21:42 | tagi:
Pxfonts/qxfonts gryzie się inputenc

Zaczęło się od tego, że LaTeX złożył tabelę w taki sposób, iż wszystkie wiersze zostały nałożone na siebie, tworząc jeden wiersz. Usuwając kolejno dołączane pakiety ustaliłem, że ww. dziwny efekt jest spowodowany błędem w pakiecie pxfonts (qxfonts oczywiście też)... A objawia się, jeżeli pakiet ów jest dołączony łącznie z pakietem inputenc.

Gorzej... Czego nie widać na pierwszy rzut oka, pxfonts przedefiniowuje LaTeXa, a konkretnie polecenie \k, które zamiast wstawiać znak ą albo ę wstawia dwa nałożone na siebie znaki, np. aogonek. Tak się składało polskie teksty w LaTeXu 20 lat temu...

Za powyższe anomalie odpowiada w pakiecie pxfonts wewnętrzne polecenie: \T@n@@nc@d@ngM@cr@M@d. Wydaje się, że wystarczy wpisać do preambuły:

\def\T@n@@nc@d@ngM@cr@M@d{}

aby usunąć błąd. (Wszystko będzie też OK, jeżeli w tekście nie pojawi się znak zawierający ogonek...)

Do tej pory uważałem pakiety pxfonts/qxfonts za dobrej jakości. Do tego stopnia dobrej, że w książce Nie za krótkie wprowadzenie..., które współtłumaczyłem jest on polecany. Teraz zrobiłem kwerendę w google na okoliczność, i stwierdziłem, że 1) pakiety te wydają się być mało używane, 2) nie są od lat pielęgnowane i 3) można znaleźć opinie o ich kiepskiej jakości. Hmmm...

Z drugiej strony trudno jest znaleźć coś jednoznacznie lepszego...

Mini-przykład ilustrujący problemy zamieszczam poniżej:

url | Thu, 04/08/2011 10:44 | tagi:
Jeszcze jedna książka nt. LaTeXa
Okładka
Okładka

Wydali książkę, którą napisałem. Jest to jeszcze jeden podręcznik do LaTeXa.

Podręczników do LaTeXa jest multum ale mój ma być zwięzły i w miarę aktualny (takie były przynajmniej założenia). Okładka przyciąga uwagę (także logiem LaTeXa w wersji poor man's) -- ale to akurat nie jest moja zasługa.

Namiary na informację w katalogu wydawcy są tutaj. Tutaj są namiary na dodatkowe materiały. Tutaj jest zaś wersja robocza (może być trochę obszerniejsza od tej na CTANie).

Tomasz Przechlewski (2011), Praca magisterska i dyplomowa z programem LaTeX. Jak szybko tworzyć profesjonalnie wyglądające dokumenty, Wolters Kluwer Polska, Warszawa, ISBN: 978-83-264-1441-1. http://www.eoficyna.com.pl/x_C_I__P_40158734__PZTA_0D.html

url | Mon, 18/07/2011 19:25 | tagi:
Odsyłacze bibliograficzne w schemacie autor-rok

Używam pakietu natbib ograniczając się do poleceń: \citet, \citealt, \citep, \citealp, \citeyearpar oraz \citetext.

Poniższy hak powoduje, że odsyłacze wewnątrz \citet będą odzielone przecinkiem, a wewnątrz \citep -- średnikiem. (,,Standardowy'' natbib stosuje jeden ,,globalny'' znak separującego kolejne odsyłacze.)

\documentclass[a4paper]{article}
\usepackage{polski}
\usepackage[authoryear]{natbib} %%&---
%% http://tex.stackexchange.com/questions/3125/a-comma-separator-for-citet-and-a-semicolon-separator-for-citep-simultaneou
\usepackage{etoolbox}
\makeatletter
\newcommand\bibstyle@comma{\bibpunct(),a,,}
\newcommand\bibstyle@semicolon{\bibpunct();a,,}
\makeatother
\pretocmd\citet{\citestyle{comma}}\relax\relax
\pretocmd\citealt{\citestyle{comma}}\relax\relax
\pretocmd\citep{\citestyle{semicolon}}\relax\relax
\pretocmd\citealp{\citestyle{semicolon}}\relax\relax

\begin{document}
...

Sposoby użycia ilustrują poniższe przykłady:

Przeciętna wariancja wyodrębniona (\emph{average variance extracted}, AVE)
jest definiowana następująco~\citetext{por.~\citealp[s.~612]{HairetAl98};
\citealp{sztemberg-lewandowska2008}; \citealp[s.~1213--1214]{FornellLarcker81}}:

Przeciętna wariancja wyodrębniona (average variance extracted, AVE) jest definiowana następująco (por. Hair i inni, 1998, s. 612; Sztemberg-Lewandowska, 2008; Fornell i Larcker, 1981, s. 1213--1214):

Tendencje przedstawione przez Orlikowski i~Baroudiego potwierdzają inne przeglądy,
por.~\citet{AbareshiMartin2008,RungtusanathamChoiHollingworth2003,NewstedHuffMunro98}
oraz \citet{PinsonneaultKraemer1993}.

Tendencje przedstawione przez Orlikowski i Baroudiego potwierdzają także inne przeglądy, por. Abareshi i Martin (2008), Rungtusanatham i inni (2003), Newsted i inni (1998) oraz Pinsonneault i Kraemer (1993).

Model Akceptacji Technologii [...] i~akceptację systemów informacyjnych w~praktyce 
badawczej informatyki ekonomicznej~\citep{VenkateshEtAl03,VenkateshDavis00}.

Model Akceptacji Technologii (Technology Acceptance Model, TAM) jest najczęściej wykorzystywaną teorią objaśniającą wykorzystanie i akceptację systemów informacyjnych w praktyce badawczej informatyki ekonomicznej (Venkatesh i inni, 2003; Venkatesh i Davis, 2000).

Praktyka badawcza [...] oceniania w~pracach Hensleya~\citeyearpar{Hensley1999}
oraz Malhotry i~Grovera~\citeyearpar{MalhotraGrover1998}, a~w~obszarze
informatyki ekonomicznej w~pracach:
\citet{StraubBoudreauGefen2004,RaiLangWelker2002,BoudreauGefenStraub2001,Straub89}
oraz~\citet{NewstedHuffMunro98,GefenStraub2005} a~także \citet{Segars1997}

Praktyka badawcza ustalania trafności w dziedzinie nauk o zarządzaniu jest z kolei oceniania w pracach Hensleya (1999) oraz Malhotry i Grovera (1998), a w obszarze informatyki ekonomicznej w pracach: Straub i inni (2004), Rai i inni (2002), Boudreau i inni (2001), Straub (1989) oraz Newsted i inni (1998), Gefen i Straub (2005) a także Segars (1997).

url | Sun, 17/07/2011 21:48 | tagi: ,
Bieżąca odmiana pisma w LaTeX

Dokument zawierający masę skrótowców wygląda fatalnie. Wykombinowałem sobie zatem umieszczać je w poleceniu \acro:

\newcommand\acro[1]{\textsc{\lowercase{#1}}}

Problem jest jak \acro wystąpi we fragmencie składanym odmianą półgrubą (kursywą też, ale trudno--nie mam pochyłych kapitalików), bo zamiast kapitalików pojawiają się wprawdzie grube, ale małe litery. Szukałem jakiegoś pakietu na taką okoliczność -- nic mi nie wpadło w oko więc na szybko wymyśliłem coś takiego:

\def\BFseriesCode{bx} 
\newcommand\acro[1]{\ifx \f@series \BFseriesCode #1\else\textsc{\lowercase{#1}}\fi}

Deklaracja \f@series zawiera kod bieżącej odmiany; dla odmiany grubej/półgrubej (pakiet polski) będzie to bx. Zatem \ifx \f@series \BFseriesCode to test czy \f@series jest równy bx (tak to trzeba dziwacznie w LaTeXu zapisywać). Jeżeli tak, to wstawiany jest ,,goły'' argument #1, a jeżeli nie, to \textsc{\lowercase{#1}}.

url | Wed, 12/01/2011 22:59 | tagi:
Przykład wykorzystania pakietu keyval

LaTeXowe makro z dwoma opcjonalnymi i dwoma obowiązkowymi argumentami. Wartością domyślną opcjonalnych argumentów są argumenty wymagane. Można to zaimplementować następująco:

\documentclass{article}
\usepackage{keyval}
\makeatletter
 %% ...
\define@key{hopla}{foo}{\def\HoplaArgFoo{#1}}
\define@key{hopla}{bar}{\def\HoplaArgBar{#1}}
\newcommand\HoplaCommand[3][]{%
 %% `reset' wartości poleceń \HoplaArgFoo/\HoplaArgBar
 \let\HoplaArgFoo \@empty \let\HoplaArgBar \@empty
 \setkeys{hopla}{#1}%%
 %% jeżeli \HoplaArgFoo jest empty, tj. nie podano argumentu foo:
 \ifx\HoplaArgFoo \@empty \def\HoplaArgFoo{#2} \fi
 %% to samo dla \HoplaArgBar:
 \ifx\HoplaArgBar \@empty \def\HoplaArgBar{#3} \fi
  %% demonstracja:
  FooArg: \HoplaArgFoo. BarArg: \HoplaArgBar. [#2 #3]\par }
\makeatother
  %% ...
\begin{document}

\HoplaCommand[foo=OA1,bar=OA2]{Arg1}{Arg2}

\HoplaCommand[bar=OA2]{Arg1}{Arg2}

\HoplaCommand{Arg1}{Arg2}
\end{document}

BTW: plik latex.ltx zawiera \def\@empty{} -- gdyby ktoś był ciekaw co to za tajemnicze \@empty.

url | Sat, 20/11/2010 18:01 | tagi:
XeTeX (aktualizacja)

Uaktualniłem krótki wstęp do używania XeTeXa oraz przykłady tegoż używania.

url | Mon, 01/11/2010 18:11 | tagi: ,