Draw a line with an icon in the middle
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I'm new to LaTeX and I'm writing my resume using ModernCV and a lot of googling.
I use the classic style and wish to make the document look a little more visual by adding icons to the section titles. For now I plan to use FontAwesome icons.
So far, I redefined the section
command to include a third argument (the icon/character to use).
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm % third argument is [m]andatory
paraddvspace2.5ex
phantomsection
addcontentslinetocsection#2
cvitem[0ex]
colorcolor1 % Use the CV color
% Left line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
% The icon
fontsize.5cm0cm#3
% Right line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
strutsectionstyle#2 % Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
The output so far is:
It looks kinda good. However, I feel like it is a hacky solution. I have no idea of the real width of the icon so all measures (2cm, .5cm) are the result of trial and error for this specific icon. The results for other characters are just wrong:
Also there is a small undesired space inserted between the lines and the icon (we can notice for example that the space between the icon and the right line is bigger than with the left line).
I think a good solution would be to draw a single line instead of two, then draw the icon at the (computed) center of the line with a (fixed-width) white background. Is this the good approach? How can I do that?
moderncv
add a comment |Â
up vote
5
down vote
favorite
I'm new to LaTeX and I'm writing my resume using ModernCV and a lot of googling.
I use the classic style and wish to make the document look a little more visual by adding icons to the section titles. For now I plan to use FontAwesome icons.
So far, I redefined the section
command to include a third argument (the icon/character to use).
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm % third argument is [m]andatory
paraddvspace2.5ex
phantomsection
addcontentslinetocsection#2
cvitem[0ex]
colorcolor1 % Use the CV color
% Left line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
% The icon
fontsize.5cm0cm#3
% Right line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
strutsectionstyle#2 % Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
The output so far is:
It looks kinda good. However, I feel like it is a hacky solution. I have no idea of the real width of the icon so all measures (2cm, .5cm) are the result of trial and error for this specific icon. The results for other characters are just wrong:
Also there is a small undesired space inserted between the lines and the icon (we can notice for example that the space between the icon and the right line is bigger than with the left line).
I think a good solution would be to draw a single line instead of two, then draw the icon at the (computed) center of the line with a (fixed-width) white background. Is this the good approach? How can I do that?
moderncv
1
@MarcelKrüger Thanks :) It should now be compilable (I usexelatex
to process the file)
â GnxR
Aug 11 at 11:01
1
+1 just formoderncv
(and a bit for the French). My documents with accented characters, compiled withpdflatex
, require a slightly longer preamble.
â phollox
Aug 11 at 12:18
@phollox I useusepackage[francais]babel
and I'm not sure but I think the reason I usexelatex
instead ofpdflatex
is because the former expects utf-8 by default while the latter requires a declaration
â GnxR
Aug 11 at 13:45
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work inpdflatex
â phollox
Aug 13 at 1:08
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I'm new to LaTeX and I'm writing my resume using ModernCV and a lot of googling.
I use the classic style and wish to make the document look a little more visual by adding icons to the section titles. For now I plan to use FontAwesome icons.
So far, I redefined the section
command to include a third argument (the icon/character to use).
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm % third argument is [m]andatory
paraddvspace2.5ex
phantomsection
addcontentslinetocsection#2
cvitem[0ex]
colorcolor1 % Use the CV color
% Left line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
% The icon
fontsize.5cm0cm#3
% Right line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
strutsectionstyle#2 % Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
The output so far is:
It looks kinda good. However, I feel like it is a hacky solution. I have no idea of the real width of the icon so all measures (2cm, .5cm) are the result of trial and error for this specific icon. The results for other characters are just wrong:
Also there is a small undesired space inserted between the lines and the icon (we can notice for example that the space between the icon and the right line is bigger than with the left line).
I think a good solution would be to draw a single line instead of two, then draw the icon at the (computed) center of the line with a (fixed-width) white background. Is this the good approach? How can I do that?
moderncv
I'm new to LaTeX and I'm writing my resume using ModernCV and a lot of googling.
I use the classic style and wish to make the document look a little more visual by adding icons to the section titles. For now I plan to use FontAwesome icons.
So far, I redefined the section
command to include a third argument (the icon/character to use).
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm % third argument is [m]andatory
paraddvspace2.5ex
phantomsection
addcontentslinetocsection#2
cvitem[0ex]
colorcolor1 % Use the CV color
% Left line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
% The icon
fontsize.5cm0cm#3
% Right line
strutraggedleftraiseboxbaseletterheight
rulehintscolumnwidth - 2cm0.3ex
strutsectionstyle#2 % Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
The output so far is:
It looks kinda good. However, I feel like it is a hacky solution. I have no idea of the real width of the icon so all measures (2cm, .5cm) are the result of trial and error for this specific icon. The results for other characters are just wrong:
Also there is a small undesired space inserted between the lines and the icon (we can notice for example that the space between the icon and the right line is bigger than with the left line).
I think a good solution would be to draw a single line instead of two, then draw the icon at the (computed) center of the line with a (fixed-width) white background. Is this the good approach? How can I do that?
moderncv
moderncv
edited Aug 11 at 13:59
asked Aug 11 at 10:23
GnxR
1286
1286
1
@MarcelKrüger Thanks :) It should now be compilable (I usexelatex
to process the file)
â GnxR
Aug 11 at 11:01
1
+1 just formoderncv
(and a bit for the French). My documents with accented characters, compiled withpdflatex
, require a slightly longer preamble.
â phollox
Aug 11 at 12:18
@phollox I useusepackage[francais]babel
and I'm not sure but I think the reason I usexelatex
instead ofpdflatex
is because the former expects utf-8 by default while the latter requires a declaration
â GnxR
Aug 11 at 13:45
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work inpdflatex
â phollox
Aug 13 at 1:08
add a comment |Â
1
@MarcelKrüger Thanks :) It should now be compilable (I usexelatex
to process the file)
â GnxR
Aug 11 at 11:01
1
+1 just formoderncv
(and a bit for the French). My documents with accented characters, compiled withpdflatex
, require a slightly longer preamble.
â phollox
Aug 11 at 12:18
@phollox I useusepackage[francais]babel
and I'm not sure but I think the reason I usexelatex
instead ofpdflatex
is because the former expects utf-8 by default while the latter requires a declaration
â GnxR
Aug 11 at 13:45
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work inpdflatex
â phollox
Aug 13 at 1:08
1
1
@MarcelKrüger Thanks :) It should now be compilable (I use
xelatex
to process the file)â GnxR
Aug 11 at 11:01
@MarcelKrüger Thanks :) It should now be compilable (I use
xelatex
to process the file)â GnxR
Aug 11 at 11:01
1
1
+1 just for
moderncv
(and a bit for the French). My documents with accented characters, compiled with pdflatex
, require a slightly longer preamble.â phollox
Aug 11 at 12:18
+1 just for
moderncv
(and a bit for the French). My documents with accented characters, compiled with pdflatex
, require a slightly longer preamble.â phollox
Aug 11 at 12:18
@phollox I use
usepackage[francais]babel
and I'm not sure but I think the reason I use xelatex
instead of pdflatex
is because the former expects utf-8 by default while the latter requires a declarationâ GnxR
Aug 11 at 13:45
@phollox I use
usepackage[francais]babel
and I'm not sure but I think the reason I use xelatex
instead of pdflatex
is because the former expects utf-8 by default while the latter requires a declarationâ GnxR
Aug 11 at 13:45
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work in
pdflatex
â phollox
Aug 13 at 1:08
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work in
pdflatex
â phollox
Aug 13 at 1:08
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can use a hbox
to fix a specific width, then use leaders
to fill the box on both sides with a line until the specified width is reached:
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm% third argument is [m]andatory
paraddvspace2.5ex%
phantomsection%
addcontentslinetocsection#2%
cvitem[0ex]%
struthbox to hintscolumnwidth%
colorcolor1%
fontsize.5cm0cmselectfont
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
space #3
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
%
%
strutsectionstyle#2% Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
You might notice that a lot of lines are ended with %
. Without this TeX inserts a space there which destroys the symmetrie.
Awesome, thanks! I replaced the hrules withleadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.
â GnxR
Aug 11 at 13:37
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can use a hbox
to fix a specific width, then use leaders
to fill the box on both sides with a line until the specified width is reached:
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm% third argument is [m]andatory
paraddvspace2.5ex%
phantomsection%
addcontentslinetocsection#2%
cvitem[0ex]%
struthbox to hintscolumnwidth%
colorcolor1%
fontsize.5cm0cmselectfont
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
space #3
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
%
%
strutsectionstyle#2% Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
You might notice that a lot of lines are ended with %
. Without this TeX inserts a space there which destroys the symmetrie.
Awesome, thanks! I replaced the hrules withleadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.
â GnxR
Aug 11 at 13:37
add a comment |Â
up vote
3
down vote
accepted
You can use a hbox
to fix a specific width, then use leaders
to fill the box on both sides with a line until the specified width is reached:
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm% third argument is [m]andatory
paraddvspace2.5ex%
phantomsection%
addcontentslinetocsection#2%
cvitem[0ex]%
struthbox to hintscolumnwidth%
colorcolor1%
fontsize.5cm0cmselectfont
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
space #3
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
%
%
strutsectionstyle#2% Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
You might notice that a lot of lines are ended with %
. Without this TeX inserts a space there which destroys the symmetrie.
Awesome, thanks! I replaced the hrules withleadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.
â GnxR
Aug 11 at 13:37
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can use a hbox
to fix a specific width, then use leaders
to fill the box on both sides with a line until the specified width is reached:
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm% third argument is [m]andatory
paraddvspace2.5ex%
phantomsection%
addcontentslinetocsection#2%
cvitem[0ex]%
struthbox to hintscolumnwidth%
colorcolor1%
fontsize.5cm0cmselectfont
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
space #3
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
%
%
strutsectionstyle#2% Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
You might notice that a lot of lines are ended with %
. Without this TeX inserts a space there which destroys the symmetrie.
You can use a hbox
to fix a specific width, then use leaders
to fill the box on both sides with a line until the specified width is reached:
documentclass[a4paper, 11pt, color, final, roman]moderncv
usepackage[scale=0.9]geometry
AtBeginDocumentrecomputelengths
usepackagefontspec
moderncvstyleclassic
moderncviconsawesome
sethintscolumnlength3cm
RenewDocumentCommandsectionsmm% third argument is [m]andatory
paraddvspace2.5ex%
phantomsection%
addcontentslinetocsection#2%
cvitem[0ex]%
struthbox to hintscolumnwidth%
colorcolor1%
fontsize.5cm0cmselectfont
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
space #3
leadershrule width-baseletterheight heightdimexprbaseletterheight+0.3exrelaxhfill
%
%
strutsectionstyle#2% Section title
firstnamegnxr
lastnamedemo
begindocument
sectionCompétencesfaWrench
closesection
enddocument
You might notice that a lot of lines are ended with %
. Without this TeX inserts a space there which destroys the symmetrie.
answered Aug 11 at 11:26
Marcel Krüger
10.4k11032
10.4k11032
Awesome, thanks! I replaced the hrules withleadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.
â GnxR
Aug 11 at 13:37
add a comment |Â
Awesome, thanks! I replaced the hrules withleadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.
â GnxR
Aug 11 at 13:37
Awesome, thanks! I replaced the hrules with
leadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.â GnxR
Aug 11 at 13:37
Awesome, thanks! I replaced the hrules with
leadershrule width-0pt depth-3pt height 5pthfill
(negative depth to control vertical positioning). For some reason positioning with raisebox didn't work.â GnxR
Aug 11 at 13:37
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445623%2fdraw-a-line-with-an-icon-in-the-middle%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
@MarcelKrüger Thanks :) It should now be compilable (I use
xelatex
to process the file)â GnxR
Aug 11 at 11:01
1
+1 just for
moderncv
(and a bit for the French). My documents with accented characters, compiled withpdflatex
, require a slightly longer preamble.â phollox
Aug 11 at 12:18
@phollox I use
usepackage[francais]babel
and I'm not sure but I think the reason I usexelatex
instead ofpdflatex
is because the former expects utf-8 by default while the latter requires a declarationâ GnxR
Aug 11 at 13:45
Indeed. There are several lines required to set your document. I struggled a lot with that in my first LaTeX document. For some reason, the school template was saved in Latin1 encoding, not UTF-8, and there were even more lines to make it work in
pdflatex
â phollox
Aug 13 at 1:08