jeudi 4 décembre 2014

Add caution and warning messages to book


I am new to LyX, and am using v2.1.2 with the book class. In addition to help with my specific questions, I would appreciate any feedback if there is a better way to achieve my desired results. Sorry if this is overly long, I was not sure how to break it into smaller posts given the background information necessary to understanding the problems.


I have made several new environments based on 'quotation' to set notice, caution, and warning messages apart from normal paragraphs, to emphasize them in a user manual. These special paragraphs have wider margins, may have bold text, may have different color text, and will begin with a label of the type of message: 'Note:', 'Warning:', 'Caution:'. I would like to use a hanging indent so the label stands alone to the left of the paragraph:



Note: Efdfd gdgfdf dgdfd dfere dfere geef geeds etjlj gelj ekjld glegee
ljkjlj ekek eskie ekeke.


I have moved stdlayouts.inc from the programs area (Windows) to the user area, duplicated the 'Quotation' style, and modified it into a new style 'Note' as shown below (similar styles for 'Caution' and 'Warning' have also been added but are not shown here):



Style Note
Category MainText
Margin Static
LatexType Environment
LatexName note
LabelString "NOTE: "
NextNoIndent 1
LeftMargin MMM
RightMargin MMM
ParIndent 0
ParSkip 0
ItemSep 0
TopSep 0.5
BottomSep 0.5
ParSep 0.2
Align Block
AlignPossible Block, Left, Right, Center
Font
Series Bold
Color Black
EndFont
HTMLTag blockquote
HTMLItem div
Preamble
\newenvironment{note}
{\quotation\hangindent=2cm\color[rgb]{1,0.2,0.3}{NOTE: }}
{\endquotation}
EndPreamble
End


The pdf output is very close to what I want. The wider margins, bold font, and color are all working, but the hanging indent is not. Also, the second 'note' paragraph is the same color as the following 'caution' paragraph rather than the color of the first 'note' paragraph.


'Note' and 'Caution' PDF Output:


'Note' pdf output


LyX code using 'Note' and 'Caution':



These safety-related terms appear in this manual:
\begin{note}
Statements identify information that you should consider before moving
to the next instruction or choice. Statements identify information
that you should consider before moving to the next instruction or
choice. Statements identify information that you should consider before
moving to the next instruction or choice.

Statements identify information that you should consider before moving
to the next instruction or choice. Statements identify information
that you should consider before moving to the next instruction or
choice. Statements identify information that you should consider before
moving to the next instruction or choice.\end{note}
\begin{caution}
Statements identify conditions or practices that could result in damage
to the equipment, the software, or other property.\end{caution}


Question 0: The second 'note' paragraph is definitely in the 'note' environment, see LyX code immediately above, so why is the color in the second paragraph different in the pdf output (it is OK in the LyX display)? How do I fix it?


Question 1: How do I get the hanging indent to work, and how to code the length of the label to get the indentation right for different length labels? I would like to use this on the pdf output and for LyX's on screen display.


Question 2: If I decide not to use the hanging indent, how do I change the 'note' environment so each paragraph in the pdf output does not start with an indentation? The LyX display is OK here.


Question 3: In the 'note' style I tried to add a LabelString to use "Note: " as a prefix to the paragraph in the LyX display, so that it would not need to be typed in each time. This is not working (I am just guessing on how to do this). Is this possible, and if so, how? The environment code does do this correctly in the pdf output.


Question 4: Is there any way to add a graphic to the beginning of the 'note' or 'caution' paragraph so that it will show up in both the LyX display and the pdf output?


Question 5: Is there any document that describes the various parameters used in the .inc file's style sections? I have not been able to find any reference.


Thank you!





pgf plots, barplot, irregular spacing between bars/columns


;-)


I've created a (grouped) bar plot with 3 groups of bars/columns, but it would be great if the space between the first and the second group would be a bit larger than the space between the second and third group of bars. How can I reach this (that is irregular x axis scaling)?


Thanks in advance!


PS: This is what I mean. ;)


enter image description here





Describing and referencing exercises in latex


I would be like reference the exercises have done such that it says


Exercise 1 (Author [number], Chapter i, Exercise i.j )



\documentclass[a4paper, 11pt, notitlepage]{report}

\usepackage{amsfonts} % if you want blackboard bold symbols e.g. for real numbers
\usepackage{graphicx} % if you want to include jpeg or pdf pictures
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{float}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{Def}[thm]{Definition}
\newtheorem{cond}[thm]{Condition}
\newtheorem{rem}[thm]{Remark}
\newtheorem{conj}[]{Conjecture}
\newtheorem*{post}{Postulate 1}
\newtheorem*{post2}{Postulate 2}
\newtheorem{ex}{Exercise}
\newtheorem{exa}[thm]{Example}

\title{BLANK} % change this
\author{BLANK} % change this
\date{\today} % change this

\numberwithin{equation}{section}

\newcommand{\mres}{\mathbin{\vrule height 1.6ex depth 0pt width
0.13ex\vrule height 0.13ex depth 0pt width 1.3ex}}

\DeclareMathOperator{\proj}{proj}

\begin{document}
\end{document}




Wrong intersection and position computations \anchorborder of \pgfdeclareshape


I'm trying to define a "labeled icon" shape (LIS), that is an icon (drawn with pgf commands, but replaced by a simple rectangle here for simplicity) with a label that is stuck to the icon (not the case in this minimal example for simplicity) and is part of the shape (border anchors are at the border of the icon AND of the label).


By using this shape I would get a result similar to the following image; except that, when the label is on the way of the edge, the edge would stop at the border of the label instead of crossing it.


Near desired result


The above image was obtained by the code:



\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\fill[red] (0,0) circle (1pt);
\node[draw, label=-90:{Some text}] (node) at (0,0) {};
\foreach \angle in {0,30,...,330} {
\node[draw, label=-\angle:{Some text}] (node-\angle) at (\angle:5cm) {};
\draw (node) -- (node-\angle);
}
\end{tikzpicture}

\end{document}


Using the LIS shape, I would write:



\documentclass{article}

\usepackage{tikz}
\usepackage{minimal-shapes}

\begin{document}

\begin{tikzpicture}
\fill[red] (0,0) circle (1pt);
\node[lis, align=center] (lis) at (0,0) {Some\\text};
\foreach \angle in {0,30,...,330} {
\node[lis, lis label pos=-\angle, align=center] (lis-\angle) at (\angle:4cm) {LIS \\ \angle};
\draw (lis) -- (lis-\angle);
}
\end{tikzpicture}

\end{document}


I have defined the LIS shape in the file minimal-shapes.sty. Everything works fine except for the computations of the border anchors where it seems that the saved values are wrong and the text position and other points are shifted by 180 degrees. Here is the adapted shape declaration that emphasizes the problem. For debugging, the anchor border returned is always the one of the icon, but a small circle is drawn where the anchor border should be on the label border.



\usepgflibrary{intersections}

\pgfkeyssetvalue{/tikz/lis label pos}{-90}

\newlength{\lis@textWidth} \newlength{\lis@textHeight}

\newcommand{\setTextCenterCoords}[0]{
%% SIMPLIFIED VERSION
\pgfmathsetlength{\pgfutil@tempdima}{\wd\pgfnodeparttextbox / 2 + 1.5em}
\pgfpointpolar{\lis@labelPos}{\pgfutil@tempdima}
}

\pgfdeclareshape{lis}{
%% DIMENs
\saveddimen{\textWidth}{
\pgf@x=\wd\pgfnodeparttextbox
\ifdim\pgf@x<\pgfshapeminwidth
\pgf@x=\pgfshapeminwidth
\fi
}
\saveddimen{\textHeight}{\pgf@x=\ht\pgfnodeparttextbox}
%% MACROs
\savedmacro{\computeActorDimens}{
\setlength{\lis@textHeight}{\ht\pgfnodeparttextbox}
\setlength{\lis@textWidth}{\wd\pgfnodeparttextbox}
}
\savedmacro{\lis@labelPos}{
\pgfmathsetmacro{\lis@labelPos}{Mod((\pgfkeysvalueof{/tikz/lis label pos} + 180), 360) - 180}
\pgfwarning{Lis label pos: \pgfkeysvalueof{/tikz/lis label pos} -> \lis@labelPos}
}
%% SAVEDANCHORs
\savedanchor{\upperRightIconCorner}{
\pgfpoint{1em}{1em}
}
\savedanchor{\textCenter}{
\setTextCenterCoords
}
\savedanchor{\upperRightTextCorner}{
\computeActorDimens % Saveddimen do not seem available when declaring saved anchors
\setTextCenterCoords
\pgfmathsetlength{\pgf@x}{\pgf@x + (.5 * \lis@textWidth)}
\pgfmathsetlength{\pgf@y}{\pgf@y + (.5 * \lis@textHeight)}
}
%% ANCHORs
\anchor{center}{\pgfpointorigin}
\anchor{text}{
\textCenter
\pgfmathsetlength{\pgf@x}{\pgf@x - (.5 * \textWidth)}
\pgfmathsetlength{\pgf@y}{\pgf@y - (.5 * \textHeight)}
}
%% BORDER ANCHORs
\anchorborder{%
\@tempdima=\pgf@x \@tempdimb=\pgf@y
%
%\computeActorDimens
\textCenter
\upperRightTextCorner
\pgfintersectionofpaths{
\pgfpathmoveto{\pgfpointorigin}\pgfpathlineto{\pgfpoint{\@tempdima}{\@tempdimb}}
\pgfgetpath\temppath
%\pgfusepath{stroke}
\pgfsetpath\temppath
}{
\pgfpathrectanglecorners{
\pgfpointlineattime{-1}{
\textCenter
}{
\upperRightTextCorner
}
}{
\upperRightTextCorner
}
\pgfgetpath\temppath
%\pgfusepath{stroke}
\pgftext[at=\textCenter]{\footnotesize \lis@labelPos}
\pgfsetpath\temppath
}
%
\pgfwarning{Nb intersections: \pgfintersectionsolutions}
%
\ifnum\pgfintersectionsolutions=0
\pgfpointborderrectangle{\pgfpoint{\@tempdima}{\@tempdimb}}{\upperRightIconCorner}
\else
\pgfintersectionsortbyfirstpath
\pgfpathcircle{\pgfpointintersectionsolution{\pgfintersectionsolutions}}{3pt}
\fi
\pgfpointborderrectangle{\pgfpoint{\@tempdima}{\@tempdimb}}{\upperRightIconCorner}
}
%% DRAWINGs
\backgroundpath{
%% SIMPLIFIED VERSION
\upperRightIconCorner \@tempdima=\pgf@x \@tempdimb=\pgf@y
\pgfpathrectanglecorners{
\pgfpointlineattime{-1}{\pgfpointorigin}{\pgfpoint{\@tempdima}{\@tempdimb}}
}{\pgfpoint{\@tempdima}{\@tempdimb}}
\pgfusepath{stroke}
}
}


With the above code, I get the following result:


Near desired result


It seems to nearly work fine for the central node. But the peripheral nodes have a wrong value for \lis@labelPos (which as been displayed to show the problem). An intersection (displayed as circles) is found when there should be one, but it appears on the wrong side of the node. If I unquote the first "\pgfusepath{stroke}", the lines go towards the outside of the figure instead of going towards the central node (the values \pgf@x and \pgf@y provided to \anchorborder seem to be wrong).


I don't understand what's happening. Can someone help ? Thanks





Chess Notation with skak: How to highlight squares?


i'm using the skak-package for some chess notation in a presentation. My only issue: How can i highlight various squares on the chessboard? Basic:



\documentclass[12pt]{beamer}
\usepackage{skak}

\begin{document}
\begin{frame}
\newgame
\fenboard{8/8/8/3Q4/8/8/8/8 w - - 0 0} % FEN-notation, only one Queen
\showboard
\end{frame}
\end{document}


For example, i want to show the possible movements for a Queen on the board. I've tried the \highlight{} command (see below), but it throws errors.



\documentclass[12pt]{beamer}
\usepackage{skak}

\begin{document}
\begin{frame}
\newgame
\fenboard{8/8/8/3Q4/8/8/8/8 w - - 0 0} % FEN-notation, only one Queen
\showboard
\highlight{d4,d6}
\end{frame}
\end{document}


Shown Error: !Undefined control sequence. <recently read> \c@lor@to@ps l.49 \end{frame}. I use Texmaker with PdfLatex.


So, whats wrong?





Copyright text as table on first page of an article in memoir class


I try to make a copyright text and suggested citation as table, appearing only on the first page of an article, breaking the abstract to the next page if necessary. So far, I had no great success. I tried to manipulate the footer on the first page, but this is not a very solid solution. I want to keep it as simple as possible, since I want to combine various articles into a annual edition of a journal (using the combine class, probably).


Here is a code example:



% *****************************Document Class***************************************
\documentclass[12pt,twoside,a4paper,article]{memoir}
% **********************************************************************************
\usepackage[utf8]{inputenc}
\usepackage{graphics}
\usepackage{csquotes}
\setquotestyle{ngerman}
\usepackage[ngerman,english]{babel}

\usepackage{hyperref}

\usepackage{lipsum} % This package generates blind text. It's not part of the example per se...


\clubpenalty=10000
\widowpenalty=10000
\displaywidowpenalty=10000


% *******************Page Style: Page Margins*************************************


\usepackage[inner=3.5cm,outer=3cm]{geometry}

%********************************************************************************

\setcounter{secnumdepth}{-1}
% ********************************************************************************

% ****************************Abstract Keywords***********************************
\def\keywordsG#1{{\textbf{Schlagworte}:} \textit{{#1}}} %
\def\keywordsEN#1{{\textbf{Keywords}:} \textit{{#1}}} %
% ********************************************************************************



\makeoddhead{plain}{\textit{Journal of all Journals (9) 2014} }{}{}
\makeevenhead{plain}{}{}{\theauthor}
\makeoddfoot{plain}{\\ \thepage}{}{}
\makeevenfoot{plain}{}{}{\\ \thepage}
\setheadfoot{\onelineskip}{3\onelineskip}
%\setheaderspaces{*}{1.5\onelineskip}{*}

\copypagestyle{firstpage}{plain}
\makeoddhead{firstpage}{\textit{Journal of all Journals (9) 2014} }{}{}
\makeevenhead{firstpage}{}{}{\theauthor}
\makeoddfoot{firstpage}{



\begin{tabular}{r p{10cm}}
\hline \\
creative commons & This work is published under a Creative-Commons-License (Attribution-Share Alike 4.0). More information at \url{http://ift.tt/18BcYvD}.\\
\hline \\
Published by: & Journal of all Journals,
ISSN 1111-2222 /

URL: \url{http://ift.tt/12z6Oul},
URN: urn:nbn:de:000-11111111-2\\
&\\
Suggested citation: & A. Author. 2014. \enquote{Title. Subtitle}. \textit{Journal of all Journals} 9(1), pp-pp. \\
\hline \\
\end{tabular}
}{\\ \thepage}{}
\makeevenfoot{firstpage}{}{\thepage}{}
\aliaspagestyle{title}{firstpage}

\setlength{\textheight}{450pt}



% ******************************Title & Author Info*********************************
\author{A. Author}
\date{}
\title{A Wonderful Title}
% *********************************************************************************



\pagestyle{plain}
\begin{document}
\maketitle
\rule{\textwidth}{0.4pt}
% ********************German Abstract & Keywords***********************************
\selectlanguage{ngerman}
\abstractrunin
\abslabeldelim{:}
\begin{abstract}
Vivamus eu tellus sed tellus consequat suscipit. Nam orci orci, malesuada id, gravida nec, ultricies vitae, erat. Donec risus turpis, luctus sit amet, interdum quis, porta sed, ipsum. Suspendisse condimentum, tortor at egestas posuere, neque metus tempor orci, et tincidunt urna nunc a purus. Sed facilisis blandit tellus. Nunc risus sem, suscipit nec, eleifend quis, cursus quis, libero. Curabitur et dolor. Sed vitae sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas ante. Duis ullamcorper enim. Donec tristique enim eu leo. Nullam molestie elit eu dolor. Nullam bibendum, turpis vitae tristique gravida, quam sapien tempor lectus, quis pretium tellus purus ac quam. Nulla facilisi.
\\

\keywordsG{Schlagwort1, Schlagwort 2, Schlagwort 3, Schlagwort 4}
\end{abstract}

% **********************************************************************************
\setlength{\textheight}{634pt}
%*********************English Abstract & Keywords***********************************
\selectlanguage{english}
\abstractrunin
\abslabeldelim{:}
\begin{abstract}
Vivamus eu tellus sed tellus consequat suscipit. Nam orci orci, malesuada id, gravida nec, ultricies vitae, erat. Donec risus turpis, luctus sit amet, interdum quis, porta sed, ipsum. Suspendisse condimentum, tortor at egestas posuere, neque metus tempor orci, et tincidunt urna nunc a purus. Sed facilisis blandit tellus. Nunc risus sem, suscipit nec, eleifend quis, cursus quis, libero. Curabitur et dolor. Sed vitae sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas ante. Duis ullamcorper enim. Donec tristique enim eu leo. Nullam molestie elit eu dolor. Nullam bibendum, turpis vitae tristique gravida, quam sapien tempor lectus, quis pretium tellus purus ac quam. Nulla facilisi.
\\

\keywordsEN{keyword1, keyword 2, keyword 3, keyword 4}
\end{abstract}

% **********************************************************************************

\pagestyle{plain}
\selectlanguage{ngerman}

% ***************************TABLE OF CONTENT***************************************
\renewcommand{\contentsname}{Content}
\tableofcontents*
% **********************************************************************************


\section{First section}
\lipsum
\section{Second Section}
\lipsum
\end{document}


What I want it to look like (as it looks right now, but the way is the problem) is that the copyright text and stuff should appear on the first page, right above the page number, below the main text, and this table should force the main text to break to the next page, if necessary. Is there a better way? There must be, I bet. This seems very clumsy to me...





Set a transparent icon in beamer's bibliography


I want to \uncover a citation in a particular overlay. The problem is that the bibliography's item icon (article in this case) is not set as transparent, but the text is.


How can I make the icon transparent also?


Here is the MWE:



\documentclass{beamer}

\begin{document}

\begin{frame}
\setbeamercovered{transparent}

\begin{thebibliography}{1}
\uncover<1>{
\setbeamertemplate{bibliography item}[article]
\bibitem{}
\scriptsize Doe, J. (1975).
\newblock\scriptsize Title of the first paper.
\newblock {\em Journal.}
}
\uncover<1-2>{
\setbeamertemplate{bibliography item}[article]
\bibitem{}
\scriptsize Doe, J. (1980).
\newblock\scriptsize Title of the second paper.
\newblock {\em Journal.}
}
\end{thebibliography}

\end{frame}

\end{document}


And here is the output:


output gif