LyXHow do I insert a character with a different font in a table

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
clemens
Posts: 77
Joined: Fri Jun 26, 2009 11:57 am

How do I insert a character with a different font in a table

Post by clemens »

Hello, I am using Lyx with Texlive and XeTex (I have various otf and ttf fonts to use in the same document)
I tried wrapping the character with the following command {\fontspec{otherfontname}DIFFERENT CHARACTER} but it gives me error.
What should I do?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: How do I insert a character with a different font in a table

Post by phi »

Please post an MWE.
clemens
Posts: 77
Joined: Fri Jun 26, 2009 11:57 am

Re: How do I insert a character with a different font in a table

Post by clemens »

Thanks for the reply. Actually it gives me a square with an X in it (last column, third row)although I am sure it is the right font name. I am adding a .lyx file (renamed to .tex to avoid the site filters) and a pdf file.
In the Lyx file I have also included another thing that creates problems, the \linebreak command, which I would like to use since otherwise the text is no broken where I like it the most. I thought I just had to put it with no spaces before or behind and it would work but now I am not so sure since I am a complete beginner.
Cheers
Attachments
different_character_in_table.pdf
(68.85 KiB) Downloaded 314 times
different character in table.tex
(12.05 KiB) Downloaded 364 times
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: How do I insert a character with a different font in a table

Post by meho_r »

That file is a mess. You sure you exported it as "LaTeX (plain)"?

BTW, I tried creating a table and using \fontspec method, it worked. Import the file in attachment in LyX (or any LaTeX editor) and try it.
Attachments
test.tex
(915 Bytes) Downloaded 309 times
clemens
Posts: 77
Joined: Fri Jun 26, 2009 11:57 am

Re: How do I insert a character with a different font in a table

Post by clemens »

Hi!
Thank you for the example. I can see it works well but somehow, when I try to do the same in my table, instead of the proper character I get a square with an X inside it. I checked the character also in OO and in gnucharmap and it should be the right one.
The example I posted was just a plain .lyx file but apart from the font change oddity, I included another thing that was giving me some problems, \linebreak that I cannot get Lyx to accept.
I read that putting this command inside a cell with no spaces before would break the line in the cell, but perhaps I got it wrong :oops:
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

How do I insert a character with a different font in a table

Post by meho_r »

For linebreak, try \par instead. If you get to large space, you may try adding a negative \vspace, e.g.:

Code: Select all

 ...some text\par\vspace{-2pt} the rest of the text... & ...
Can you send me that other font you're using to try to compile that file?

EDIT: I've found out what is causing the problem with line break. When entering a command, you must put immediately after it a space or finish it with {} because LaTeX must know where the command ends. E.g.

Code: Select all

 \linebreaksome text
This is wrong as you can see. In your .lyx file both \linebreak touch the text that is following it, so either put a space behind ERT box, or enter \linebreak{}. So the command should be:

Code: Select all

\linebreak{}some text or
\linebreak some text
Try it. Keep in mind that LaTeX eats the space after commands. E.g.:

Code: Select all

 Test\ldots test
will produce:

Code: Select all

 Test...test 
You may correct it (that is, to have a space after ellipsis) this way:

Code: Select all

 Test\ldots{} test 
(notice the space after {}) or this way:

Code: Select all

 Test\ldots\ test
Both these last codes will produce:

Code: Select all

 Test... test 
clemens
Posts: 77
Joined: Fri Jun 26, 2009 11:57 am

Re: How do I insert a character with a different font in a table

Post by clemens »

Wow!
Thank you very much.
Here is the font, just in case
http://rapidshare.com/files/271910829/simsun.tcc.html
I have so many other questions :oops:
One is related to the front matter.
I put after the front page a table of contents and after it some more front matter such as an introduction with some subsections using the starred typologies (no numbers, chapter and sections) but in the table of contents these do not appear. Is there a way to do it?
How do I select backmatter apart from bibliography in memoir?
I would like to add some appendices
I was also wondering if there is a way to have a list of images at the end of the work (fig.1 NAME, fig.2 NAME), after the appendices and after that the images proper. In the main body I refer to those images (as fig. 1, fig.2 etc.), it would be nice to link them as well.
The last thing is, how do I enter bibliographies. I like the Harvard style (Author date. Title, etc (City:Publisher))
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

How do I insert a character with a different font in a table

Post by meho_r »

Most of your questions are answered before on this forum, so you should search a little ;) However, some tips.

1. If you use frontmatter, you don't have to use starred version of sectioning command because they aren't numbered when in frontmatter. So, use normal \chapter, \section etc. Your document should have structure like in this example:

Code: Select all

\frontmatter
\tableofcontent

\chapter{Introduction}
...some text...

\mainmatter
\chapter{Some chapter}
...some text...

\backmatter
...Appendicies, Bibliography etc.
2. For referencing, use \label{some_label} and when you need to refer to it, use \ref{some_label}. For images and List of figures you'll have to use \caption{picture_name} too, as well for tables. When you follow this guideline, you simply enter \listoffigure and \listoftables commands where you want them to appear (they are similar to \tableofcontent). You should check out caption package for details about captions and some examples.

3. About all this you may learn some basics in LyX User's Guide and other literature. I'll repeat what I said before, you should consider obtaining LaTeX Companion, 2nd edition which is a must-have for serious LaTeXing. For basics, you may try with Not So Short Introduction to LaTeX or obtain "Guide to LaTeX", 4th edition. It's up to you. LaTeX is a very powerful system, arguably the most powerful typesetting system in the world, it has rules you'll have to learn and obey. That means you'll have to do a lot of reading if you want to use all its advantages. But consider it investment...
clemens
Posts: 77
Joined: Fri Jun 26, 2009 11:57 am

Re: How do I insert a character with a different font in a table

Post by clemens »

Thank you again for all the information and sorry for my laziness in searching :oops:
I am originally coming from the WYSIWYG world and now I am just at the basic Lyx level so all the direct Latex commands are still quite difficult and confusing (especially when there are many connected).
As soon as I can find the time I will start to seriously study Latex as well since I agree it is a real investment.
I have downloaded the free guide and as soon as possible I will order the Guide to Latex.
Cheers
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

How do I insert a character with a different font in a table

Post by meho_r »

:) You didn't say, is the problem with \linebreak solved?

As for the font, I really can't say anything, couldn't get it working. You may try on mailing list, maybe someone who works with Japanese or other East Asian languages can help. Generally, that crossed rectangle means that character isn't available, but you say you're sure it's correct. May be font or language issue.

BTW, here is a real quick guide with examples to test, may be useful. Still, don't hesitate to ask :)
Post Reply