-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple latex to pdf using tikz #29
Labels
Comments
make_external_latex<-function(
latex="testing123",
filename=NULL
)paste0(
if(!is.null(filename)){paste0("\\tikzsetnextfilename{",filename,"}"," ")}else{""},
"\\tikz{\\path (0,0) node[inner sep=0,outer sep=0]{",
latex,
"};}"
) |
for pair icons, we have a function that paints the icon ofr a pair using tikz pair_icon<-function(
pair,
pair_exposure,
pair_days,
pair_pnl,
pair_long_pnl,
pair_short_pnl,
drop_one_pair_pnl,
local_pnl
){
icon_items<-c(
paste0("\\multicolumn{1}{@{}c@{}}{",pair_with_pm_color(pair=pair),"}"),
paste0("\\multicolumn{1}{@{}c@{}}{",pair_price_action(pair=pair,pair_pnl=pair_pnl,w=21,height=2,width = 30,units="mm"),"}"),
paste0("\\multicolumn{1}{@{}c@{}}{",pair_technicals(
pair=pair,
w=365,
pair_exposure=pair_exposure,
pair_days=pair_days,
pair_long_pnl=pair_long_pnl,
pair_short_pnl=pair_short_pnl,
drop_one_pair_pnl=drop_one_pair_pnl,
local_pnl=local_pnl
),"}"),
pair_leg(pair=pair,pair_exposure=pair_exposure,direction=(1),max_char=12),
pair_leg(pair=pair,pair_exposure=pair_exposure,direction=(-1),max_char=12)
)
tbl(x=icon_items,sep=" \\\\ \n",align="@{}p{3.0cm}@{}")
} |
and we loop over pair icons like this: latex_icons<-mapply(pair_icon,pair=pairs,MoreArgs=list(
pair_exposure=pair_exposure,
pair_days=pair_days,
pair_pnl=pair_local_pnl,
pair_long_pnl=pair_long_pnl,
pair_short_pnl=pair_short_pnl,
drop_one_pair_pnl=drop_one_pair_pnl,
local_pnl=local_pnl
),SIMPLIFY = FALSE)
append2log("create_pair_icons.Rnw : create external latex commands")
external_latex_icons<-mapply(
function(latex,file){
make_external_latex(latex=latex,filename=file)
},
latex=latex_icons,
#file=paste0("N:/Depts/Share/UK Alpha Team/Analytics/pair_icons/",pairs),
file=paste0(pairs),
SIMPLIFY=TRUE
) |
and finally, we put the latex generated above into the doc:
|
the output looks like this: for example, pair ABC1
|
and another one:
|
the ionkey file |
amd the "create pair icons" file: |
images.csv contains a mapping of pair names to the appropriate file: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
we need to create a large number of icons representing individual pairs/shares
this is best done using a single .Rnw file which creates each icon using the tikz library
and then outputs the reulting icon per pair to the appropriate file name
The text was updated successfully, but these errors were encountered: